User Tools

Site Tools


boot_process

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
boot_process [2026-02-26 06:02 UTC (9 months ago)] – Added newlines after steps 3 and 4 to fix formatting benjaminboot_process [2026-11-22 21:44 UTC (5 days ago)] (current) – update to break down boot process further in depth, and where we can inject our own code, scripts, etc qkb
Line 1: Line 1:
 ====== Boot Process ====== ====== Boot Process ======
  
-This boot process is universal to all PROXmobil3 units as best as I can surmise.+This boot process is universal to all PROXmobil3 units as best we can tell with existing data.
  
-1. U-Boot starts up and loads the kernel from the [[storage#rootfs|rootFS]] microSD card.\\ +  - U-Boot starts from the 16 MB SPI flash (''%%mtd0%%''). It is ''%%2018.03-INIT-004%%'', built in March 2019. Its ''%%bootcmd%%'' runs ''%%sdboot%%'', then ''%%failover%%'', then ''%%sdboot%%'' again, then ''%%panicboot%%''. 
-2. The kernel loads systemd from /usr/lib/systemd/systemd.\\ +  - U-Boot loads the kernel and DTB from ''%%sda1:/boot%%'' or from the SPI copy. The ''%%.old%%'' kernel and DTB are the rollback path. The kernel command line is ''%%root=/dev/sda1 ro rootfstype=ext4 rootwait cma=128M%%''. 
-3. systemd attempts to mount the [[storage#initFS|initFS]] by searching for any partitions named ''%%init%%''. If it cannot find any volumes after 90 seconds, it shuts down.\\ +  - The root filesystem mounts read-only at ''%%/%%''. systemd is PID 1. 
-4. The kernel calls to /sbin/init, which later calls ''%%/init/tools/initexec.sh startup%%''. If the ''%%startup%%'' argument is not passed, the script tells you the only valid argument is ''%%startup%%'', then exits.\\ +  - ''%%init.mount%%'' mounts the partition labelled ''%%init%%'' at ''%%/init%%'', using ''%%/dev/disk/by-label/init%%''. The label cannot be changed. The mount unit has the normal 90-second timeout; if the init partition is missing, the boot does not complete. 
-5a. /init/tools/initexec.sh sets up a bunch of aliases and environment variables.\\ +  - ''%%init-rc.service%%'' runs ''%%/init/tools/initexec.sh startup%%''. If the ''%%startup%%'' argument is missing, the script prints its usage and exits. 
-5b. initexec.sh ensures necessary directories are created, then checks and sets the device's distribution channel.\\ +  - ''%%initexec.sh%%'' sources ''%%/init/tools/initenv.sh%%'' if it exists, which can set environment variables and aliases. It exports ''%%INIT_ROOT=/init%%'', ''%%NX_EXE=NxExe%%'', and ''%%REBOOT_FLAG%%'', and creates the runtime directories. It reads the distribution channel from ''%%efad/pgm/env.ini%%'' (''%%VertriebsWeg=72%%'' by default). 
-5c. It calls a function ''%%do_startup%%'', which checks if there is software to run, and if not, installs it via a function ''%%install_archive%%''. This function misspells "archive" to "archvie" in an echo log.\\ +  - It calls ''%%do_startup%%'', which installs any pending archives from ''%%/init/install/archive%%''. It processes the ''%%X72%%''/''%%x72%%'' files in name order, skips downgrades against ''%%BaseVersion%%'' in ''%%efad/pgm/arcinfo.dat%%'', skips archives that already have a log, runs each ''%%_install.sh%%'', and keeps the log on success. The stock log line has a typo: ''%%installed archvie%%''. 
-5d. It checks if ''%%/init/tmp/reboot.flg exists%%'', and if so, reboots the device.\\ +  - If ''%%/init/tmp/reboot.flg%%'' exists, it removes the flag and reboots. 
-5e. It calls every script located in /init/autorun/, launching /efad/pgm/NxProx (the CapMetro software), then echoes "Startup completed".software).\\+  - It runs every executable in ''%%/init/autorun/%%'' in filename order. The stock scripts are: 
 +    * ''%%10-eeprom.sh%%'' reads the mounting-plate or dongle EEPROM into ''%%/tmp/eeprom.dat%%''. 
 +    * ''%%20-ext-sdcard.sh%%'' mounts the external SD/USB at ''%%/init/efad/mp_sd%%''. 
 +    * ''%%90-testmode.sh%%'' stops nx, disables the PIC32 watchdog, extracts the ''%%[TestMode]%%'' block from ''%%/tmp/eeprom.dat%%'', and runs it as a shell script. 
 +    * ''%%99-devmode.sh%%'' stops nx and disables the watchdog if ''%%NxProx%%'' is missing. 
 +  - ''%%initexec.sh%%'' prints ''%%Startup completed%%''. The autorun scripts themselves do not launch ''%%NxProx%%''. ''%%NxProx%%'' is a systemd service. ''%%init-abtproxy.service%%'' is enabled on the stock image; ''%%nx.service%%'' is enabled or started by the unit configuration. If enabled, nx starts after ''%%init-rc.service%%''. 
 + 
 +''%%nx.service%%'' has ''%%FailureAction=poweroff%%''. If nx is stopped or crashes in the wrong way, the unit can power off. If you are working on the unit, disable the PIC32 watchdog in the same step you stop nx: 
 + 
 +<code> 
 +systemctl stop nx init-abtproxy 
 +NxExe watchdog 0 
 +</code> 
 + 
 +The PIC32 watchdog is external to the SoC. It power-cycles the unit about 60 seconds after boot unless something feeds it. nx normally feeds it. 
 + 
 +The init sequence is easy to change on purpose. Edit ''%%initexec.sh%%'', or drop a script into ''%%/init/autorun/%%''. The supported way to do that without opening the case is the ''%%[TestMode]%%'' dongle payload or an ''%%autorun%%'' script on the init SD card. 
 + 
 +===== Serial console ===== 
 + 
 +The U-Boot and kernel console is ''%%ttymxc1%%'' on the four-pin ''%%ARMcons%%'' header. Settings are 115200 8N1. Interrupt U-Boot there if you need the bootloader prompt.
  
-It is trivially easy to hijack this init sequence by modifying initexec.sh or just inserting a script into /init/autorun. 
boot_process.txt · Last modified: by qkb