Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: main build script #12

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
BUILD/
bootloader/include/boot.scr

20 changes: 20 additions & 0 deletions bootloader/0001-resolve-poweroff-issue.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
diff --git a/plat/imx/imx8m/imx8m_psci_common.c b/plat/imx/imx8m/imx8m_psci_common.c
index 4a7255657..71678e955 100644
--- a/plat/imx/imx8m/imx8m_psci_common.c
+++ b/plat/imx/imx8m/imx8m_psci_common.c
@@ -251,12 +251,11 @@ void __dead2 imx_system_off(void)
uint32_t val;

val = mmio_read_32(IMX_SNVS_BASE + SNVS_LPCR);
- val |= SNVS_LPCR_SRTC_ENV | SNVS_LPCR_DP_EN | SNVS_LPCR_TOP |
- SNVS_LPCR_LPTA_EN | SNVS_LPCR_LPWUI_EN;
+ val |= SNVS_LPCR_SRTC_ENV | SNVS_LPCR_DP_EN | SNVS_LPCR_TOP;
mmio_write_32(IMX_SNVS_BASE + SNVS_LPCR, val);
-
+ INFO("poweroff\n");
while (1)
- ;
+ ;
}

void __dead2 imx_pwr_domain_pwr_down_wfi(const psci_power_state_t *target_state)
37 changes: 37 additions & 0 deletions bootloader/include/boot.script
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Set uboot args in .header
# rootfs_part=/dev/mmcblk2p2
# kernel_comp_addr_r=0x53800000
# kernel_comp_size=0x12800000
# fdt_file=imx8mm-mecha-comet-m-gen1.dtb

# Uboot script
setenv fk_kvers '6.1.22+mecha'
setenv bootargs ${bootargs} console=${console} root=${rootfs_part}

# Setting fdt path
setenv fdt_path /usr/lib/linux-image-${fk_kvers}/freescale/${fdt_file}

fatload mmc ${mmcdev}:1 ${loadaddr} vmlinuz-${fk_kvers}
fatload mmc ${mmcdev}:1 ${initrd_addr} initrd.img-${fk_kvers}
ext4load mmc ${mmcdev}:2 ${fdt_addr} ${fdt_path}

# Apply device tree overlays
run set_fdt_overlay_addr
run set_fdt_overlays_env
run import_fdt_overlays_env
fdt addr 0x43000000
fdt resize 8192
run load_fdt_overlays
#run apply_fdt_overlays

# Boot versioned kernel
# fatload mmc ${mmcdev}:1 ${loadaddr} vmlinuz-${fk_kvers}
# fatload mmc ${mmcdev}:1 ${initrd_addr} initrd.img-${fk_kvers}
# ext4load mmc ${mmcdev}:2 ${fdt_addr} ${fdt_path}
booti ${loadaddr} ${initrd_addr}:0x12800000 ${fdt_addr}

# Boot unversioned kernel
#fatload mmc ${mmcdev}:1 ${loadaddr} vmlinux
#fatload mmc ${mmcdev}:1 ${initrd_addr} initrd.img
#ext4load mmc ${mmcdev}:2 ${fdt_addr} ${fdt_path}
#booti ${loadaddr} ${initrd_addr}:0x12800000 ${fdt_addr}
1 change: 1 addition & 0 deletions bootloader/include/overlays.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fdt_overlays=gyro-disable.dtbo
13 changes: 12 additions & 1 deletion bootloader/modules/arm-trusted-firmware.nu
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,21 @@ export def build_imx_trusted_firmware [work_dir:string] {
let manifest = $env.MANIFEST_DIR
let IMX_ATF_REPO = open $manifest | get imx-atf | get url

let patch_path = (open $manifest | get patch-path)
let patch_path = $patch_path | path expand

log_debug $"Fetching IMX Trusted Firmware source code from ($IMX_ATF_REPO) to ($imx_atf_dir)"
curl -L $IMX_ATF_REPO | tar -xz -C $imx_atf_dir --strip-components=1

# curl -L $IMX_ATF_REPO | tar -xz -C $imx_atf_dir --strip-components=1

git clone $IMX_ATF_REPO $imx_atf_dir

cd $imx_atf_dir

git checkout 99195a23d3aef485fb8f10939583b1bdef18881c

git apply $"($patch_path)/0001-resolve-poweroff-issue.patch"

make PLAT=imx8mm bl31

log_info "IMX Trusted Firmware build completed successfully"
Expand Down
94 changes: 43 additions & 51 deletions debian/build-debian.nu
Original file line number Diff line number Diff line change
Expand Up @@ -70,67 +70,46 @@ def main [machine: string, build_dir: string] {


try {
# Stage1: Setup rootfs
install_host_packages
debootstrap_deb
copy_qemu_arm_static

mount_sys_proc_volumes
#-------------------------- Stage1: Setup rootfs -----------------------------#

make_root_home_dir
# install_host_packages

install_linux_firmware_packages
install_linux_kernel_packages
# boot script
boot_script
debootstrap_deb

copy_qemu_arm_static

install_target_packages
mount_sys_proc_volumes

install_mechanix_packages
make_root_home_dir

# Stage3: Configure rootfs
configure_networking

# set_hostname
# setup_default_locale_timezone
add_debian_mechanix_source


# disable_diaply_service
disable_diaply_service

# configure_audio
configure_audio
boot_script

# update_os_release
update_os_release
install_target_packages

disable_diaply_service

# configure_udev
configure_udev
configure_audio

# configure_networking
configure_networking
update_os_release

# oem_images
oem_images
configure_udev

# enable_easysplash
# enable_easysplash $rootfs_dir
# enable_boot_fw $rootfs_dir
oem_images

# configure_bluetooth
configure_bluetooth
configure_bluetooth

# configure_ssh
configure_ssh
configure_ssh

# configure_default_user
configure_default_user
configure_default_user

# configure_greeter
configure_greeter
configure_greeter

# configure_sys_files
configure_sys_files
configure_sys_files

# Stage4: Cleanup
unmount_sys_proc_volumes
Expand All @@ -151,16 +130,16 @@ def main [machine: string, build_dir: string] {
def copy_qemu_arm_static [] {
log_info "Copying qemu-arm-static:"

let rootfs_dir = $env.ROOTFS_DIR
let rootfs_dir = $env.ROOTFS_DIR

# Check if `debootstrap` is installed
let is_qemu_arm_static_installed = dpkg -l | grep qemu-arm-static | wc -l | into int
# # Check if `debootstrap` is installed
# let is_qemu_arm_static_installed = dpkg -l | grep qemu-arm-static | wc -l | into int

# TODO: instead of checking with dpkg we can check with binary
if $is_qemu_arm_static_installed == 0 {
log_error "`qemu-arm-static` is not installed, cannot continue further"
return
}
# # TODO: instead of checking with dpkg we can check with binary
# if $is_qemu_arm_static_installed == 0 {
# log_error "`qemu-arm-static` is not installed, cannot continue further"
# return
# }

SUDO cp /usr/bin/qemu-arm-static $"($rootfs_dir)/usr/bin/"
}
Expand Down Expand Up @@ -202,9 +181,22 @@ def setup_default_locale_timezone [] {
let rootfs_dir = $env.ROOTFS_DIR


CHROOT $rootfs_dir localectl set-locale $"LANG=($TARGET_LOCALE)"
# CHROOT $rootfs_dir localectl set-locale $"LANG=($TARGET_LOCALE)"
CHROOT $rootfs_dir timedatectl set-timezone $TARGET_TIMEZONE

# TODO: Why is this disabled
#$CHROOTCMD systemctl enable systemd-timesyncd
}

def update_apt [] {
log_info "Updating apt and setting locale:"

let rootfs_dir = $env.ROOTFS_DIR
alias CHROOT = sudo chroot $rootfs_dir

# clean up and update
# CHROOT apt-get clean
# CHROOT apt-get update
CHROOT apt-get install locales
CHROOT localectl set-locale LANG=en_US.UTF-8
}
21 changes: 14 additions & 7 deletions debian/conf-packages/target.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
packages:
- firmware.group
- linux.group
- system.group
- network.group
- build.group
Expand All @@ -9,10 +11,17 @@ packages:
- graphics.group
- mechanix.group
package_groups:
- name: linux
packages:
- name: firmware
packages:
- initramfs-tools
- imx-sdma-firmware
- bluez-firmware
- u-boot-tools
- name: linux
packages:
- linux-image-6.1.22+mecha
- linux-headers-6.1.22+mecha
- linux-libc-dev=6.1.22+mecha-1
- name: system
packages:
- dbus
Expand All @@ -32,6 +41,8 @@ package_groups:
- network-manager
- net-tools
- curl
- wget
- unzip
- name: build
packages:
- python3
Expand Down Expand Up @@ -64,8 +75,4 @@ package_groups:
- libasound2-plugins
- name: mechanix
packages:
- mecha-agent


# - linux.group
# - firmware.group
- mechanix-status-bar
6 changes: 3 additions & 3 deletions debian/conf/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ os-release:
BUG_REPORT_URL: "https://forum.mecha.so/"

# make this as relative path
packages-path: ./include/packages/
scripts-path: ./include/scripts/
media-files : ./include/media-files
packages-path: ./include/
scripts-path: ../bootloader/include/
media-files : ./include/splash/
firmware-files : ./include/packages/firmware
include-path: ./include
42 changes: 42 additions & 0 deletions debian/include/10-imx.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Create symlinks for i.mx keypads and touchscreens
#SUBSYSTEM=="input" KERNEL=="event*" ATTRS{name}=="mxckpd", SYMLINK+="input/keyboard0"
#SUBSYSTEM=="input" KERNEL=="event*" ATTRS{name}=="mxc_ts", SYMLINK+="input/ts0"
#SUBSYSTEM=="input" KERNEL=="event*" ATTRS{name}=="imx_adc_ts", SYMLINK+="input/ts0"
#SUBSYSTEM=="input" KERNEL=="event*" ATTRS{name}=="mpr084", SYMLINK+="input/keyboard0"
#SUBSYSTEM=="input" KERNEL=="event*" ATTRS{name}=="tsc2007", SYMLINK+="input/ts0"
#SUBSYSTEM=="input" KERNEL=="event*" ATTRS{name} =="STMP3XXX touchscreen", SYMLINK+="input/ts0"
#SUBSYSTEM=="input" KERNEL=="event*" ATTRS{name} =="MXS touchscreen", SYMLINK+="input/ts0"
#SUBSYSTEM=="input" KERNEL=="event*" ATTRS{name} =="HannStar P1003 Touchscreen", SYMLINK+="input/ts0"
#SUBSYSTEM=="input" KERNEL=="event*" ATTRS{name} =="eGalax Touch Screen", SYMLINK+="input/ts0"

# The long class name gets cut off to be mc13783_connectiv in
# /sys/class/mc13783_connectivity/mc13783_connectivit
KERNEL=="mc13783_connectiv*", NAME="mc13783_connectivity"
# Anyone has readonly permission to IIM device file
KERNEL=="mxc_iim", MODE="0444", SYMLINK+="mxc_mem"
KERNEL=="mxs_viim", MODE="0444", SYMLINK+="mxc_mem"
KERNEL=="mxc_ipu", MODE="0666"
KERNEL=="mxc_vpu", MODE="0666"
SUBSYSTEM=="video", MODE="0660"
KERNEL=="fb[0-9]", MODE="0660", GROUP="video"
KERNEL=="gsl_kmod", MODE="0660", GROUP="video"
KERNEL=="galcore", MODE="0666", GROUP="video"

# Load hdmi/sdma/regulatory/epdc firmware
SUBSYSTEM=="platform" DRIVER=="cdns-mhdp-imx", ACTION=="add", RUN+="/etc/hdmi"
SUBSYSTEM=="platform" KERNEL=="regulatory.0", ACTION=="add", RUN+="/etc/regulatory"
SUBSYSTEM=="platform" DRIVER=="imx-sdma", ACTION=="add", RUN+="/etc/sdma"
SUBSYSTEM=="platform" KERNEL=="*.epdc", ACTION=="add", RUN+="/etc/epdc"

#Change VPU-HANTRO and dma_heap group
KERNEL=="mxc_hantro", GROUP="video"
KERNEL=="mxc_hantro_h1", GROUP="video"

SUBSYSTEM=="dma_heap", KERNEL=="system", GROUP="video"
SUBSYSTEM=="dma_heap", KERNEL=="linux,cma", GROUP="video"
SUBSYSTEM=="dma_heap", KERNEL=="linux,cma-uncached", GROUP="video"

#MECHA rules
KERNEL=="sd?", SUBSYSTEM=="block", ATTR{removable}=="1", RUN+="/bin/su root -c /usr/libexec/otaDetect.sh"
SUBSYSTEM=="net" KERNEL=="usb1", ACTION=="add", RUN+="/usr/libexec/netifchanges.sh"

Loading