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

Add support for starting the system from USB media #57

Closed
wants to merge 11 commits into from
@@ -394,7 +394,7 @@ int board_late_init(void)

if (get_boot_device() == BOOT_DEVICE_SPI) {
setenv("bootdelay", "0");
setenv("bootcmd", "run booting_from_spi");
setenv("bootcmd", "run boot_spi");
}

usbhost_early_poweron();
@@ -67,6 +67,7 @@
#define CONFIG_IR_REMOTE_POWER_UP_KEY_VAL9 0xFFFFFFFF

#define CONFIG_CMD_PXE 1

#if defined(CONFIG_CMD_PXE)
#define CONFIG_BOOTP_PXE 1
#define CONFIG_BOOTP_PXE_CLIENTARCH 0x16
@@ -77,11 +78,8 @@
#define CONFIG_BOOTP_SUBNET 1
#define CONFIG_BOOTP_DNS 1
#define CONFIG_UDP_CHECKSUM 1

#define CONFIG_MENU 1

#define CONFIG_DEFAULT_CONSOLE "ttyS0,115200n8\0"

#define ENV_PXE_DEFAULT \
"pxefile_addr_r=0x1070000\0" \
"pxeuuid=" ODROID_BOARD_UUID "\0" \
@@ -94,34 +92,59 @@
#define ENV_PXE_DEFAULT
#endif

#define ENV_MMC_LIST_DEFAULT "mmc_list=0 1\0"
#define ENV_MMC_LIST_DEFAULT "mmc_list=1 0\0"

This comment has been minimized.

@tobetter

tobetter May 31, 2019
Collaborator

We've been requested to swap the boot order from SD to eMMC, but we'd like to keep them eMMC to SD by default. Instead, we are happy to provide simple instruction to swap them by a user in Linux userspace or Android using a tool and preparing to release them by the end of next week.

This comment has been minimized.

@150balbes

150balbes May 31, 2019
Author

To set the launch order, you can use a simple text file that will quickly change the launch order as desired by a specific user.

https://github.com/150balbes/Build-Armbian/blob/master/packages/bsp/odroid-n2/set_boot_order.ini

This comment has been minimized.

@tobetter

tobetter May 31, 2019
Collaborator

To set the launch order, you can use a simple text file that will quickly change the launch order as desired by a specific user.

https://github.com/150balbes/Build-Armbian/blob/master/packages/bsp/odroid-n2/set_boot_order.ini

I know, that's what I intended to add the value "mmc_list" but not improved yet. I've guided the similar instruction to many users through the forum or PM but some of them still having a difficulty to follow it.

This comment has been minimized.

@150balbes

150balbes May 31, 2019
Author

To use it, rename it (boot.ini) and write to any media (USB or SD card). By the way, I would recommend adding a mandatory shutdown of the system after the update procedure to the Piteboot update procedure. Now this procedure is repeated cyclically and you need to catch the moment and turn off N2.


#define ENV_USB_LIST_DEFAULT "usb_list=0 1 2 3\0"

#define ENV_BOOT_ORDER_DEFAULT "boot_order=mmc rawimage usb pxe spi\0"

#define ENV_BOOTSCRIPTS_DEFAULT "boot_scripts=boot.ini boot.scr\0"

#define ENV_BOOT_ATTEMPT_DEFAULT \
"boot_attempt=" \
"for script in ${boot_scripts}; do " \
"echo \"## Attempting fetch ${script} in ${devtype}:${devnum}...\"; " \
"load ${devtype} ${devnum} ${preloadaddr} ${script}; " \
"source ${preloadaddr}; " \
"done\0"

#define ENV_MMC_DEFAULT \
"boot_mmc=" \
"setenv devtype mmc; " \
"for n in ${mmc_list}; do " \
"for n in ${mmc_list}; do " \
"setenv devnum ${n}; " \
"setenv devno ${n}; " \
"cfgload; " \
"run boot_attempt; " \
"done\0"

#define ENV_MMC_BOOT_DISTRO \
"boot_mmc_distro=" \
"setenv devtype mmc; " \
"for n in ${mmc_list}; do " \
#define ENV_USB_DEFAULT \
"boot_usb=" \
"usb start; " \
"setenv devtype usb; " \
"for n in ${usb_list}; do " \
"setenv devnum ${n}; " \
"setenv devno ${n}; " \
"load mmc ${n} ${preloadaddr} boot.scr; " \
"source ${preloadaddr}; " \
"done\0" \
"run boot_attempt; " \
"done\0"

#define ENV_BOOT_DEFAULT \
"boot_default=" \
"for x in ${boot_order}; do " \
"run boot_${x}; " \
"done\0"

/* args/envs */
#define CONFIG_SYS_MAXARGS 64
#define CONFIG_EXTRA_ENV_SETTINGS \
ENV_PXE_DEFAULT \
ENV_MMC_DEFAULT \
ENV_MMC_BOOT_DISTRO \
ENV_MMC_LIST_DEFAULT \
ENV_USB_DEFAULT \
ENV_USB_LIST_DEFAULT \
ENV_BOOTSCRIPTS_DEFAULT \
ENV_BOOT_ORDER_DEFAULT \
ENV_BOOT_DEFAULT \
ENV_BOOT_ATTEMPT_DEFAULT \
"console=" CONFIG_DEFAULT_CONSOLE \
"loadaddr=1080000\0"\
"outputmode=1080p60hz\0" \
@@ -141,7 +164,7 @@
"fdt_addr_r=0x1000000\0" \
"kernel_addr_r=0x1080000\0" \
"ramdisk_addr_r=0x3080000\0" \
"preloadaddr=0x3000000\0"\
"preloadaddr=0x4000000\0"\
"cvbs_drv=0\0"\
"osd_reverse=0\0"\
"video_reverse=0\0"\
@@ -179,7 +202,8 @@
"booti ${loadaddr} - ${dtb_mem_addr}; " \
"bootm;" \
"done\0" \
"boot_rawimage=setenv bootargs ${initargs} logo=${display_layer},loaded,${fb_addr} " \
"boot_rawimage=" \
"setenv bootargs ${initargs} logo=${display_layer},loaded,${fb_addr} " \
"vout=${outputmode},enable cvbsmode=${cvbsmode} " \
"hdmimode=${hdmimode} osd_reverse=${osd_reverse} video_reverse=${video_reverse} " \
"androidboot.selinux=permissive androidboot.firstboot=${firstboot} jtag=disable " \
@@ -191,10 +215,6 @@
"booti ${loadaddr} - ${dtb_mem_addr}; " \
"bootm; " \
"done\0" \
"boot_default="\
"run boot_mmc; " \
"run boot_mmc_distro; " \
"run boot_rawimage\0" \
"init_display="\
"osd open; osd clear; " \
"for n in ${mmc_list}; do " \
@@ -210,38 +230,54 @@
"fi; " \
"done; " \
"vout output ${outputmode};\0" \
"set_spi_params="\
"setenv start_uboot 0x0; "\
"setenv start_kernel 0x119000; "\
"setenv start_dtb 0x100000; "\
"setenv start_initrd 0x4E6C00; "\
"setenv size_kernel 0x3CDC00; "\
"setenv size_dtb 0x19000; "\
"setenv size_initrd 0x319400;\0"\
"fusing_spi_from_sd="\
"bios_offset_uboot=0x00000000\0" \
"bios_sizeof_uboot=0x0f0000\0" \
"bios_offset_ubootenv=0x000f0000\0" \
"bios_sizeof_ubootenv=0x010000\0" \
"bios_offset_petitboot=0x00100000\0" \
"bios_sizeof_petitboot=0x010000\0" \
"bios_offset_dtb=0x00110000\0" \
"bios_sizeof_dtb=0x020000\0" \
"bios_offset_kernel=0x00130000\0" \
"bios_sizeof_kernel=0x3c0000\0" \
"bios_offset_initrd=0x004f0000\0" \
"bios_sizeof_initrd=0x310000\0" \
"spiupdate_uboot="\
"sf probe; "\
"load mmc 1 ${loadaddr} u-boot.bin; "\
"sf update ${loadaddr} ${bios_offset_uboot} ${bios_sizeof_uboot}\0"\
"spiupdate_petitboot="\
"sf probe; "\
"load mmc 1 ${loadaddr} petitboot.cfg; "\
"sf update ${loadaddr} ${spi_petitboot} ${bios_sizeof_petitboot}\0"\
"spiupdate_kernel="\
"sf probe; "\
"load mmc 1 ${loadaddr} uImage; "\
"sf update ${loadaddr} ${bios_offset_kernel} ${bios_sizeof_kernel}\0"\
"spiupdate_initrd="\
"sf probe; "\
"load mmc 1 ${loadaddr} rootfs.cpio.uboot; "\
"sf update ${loadaddr} ${bios_offset_initrd} ${bios_sizeof_initrd}\0"\
"spiupdate_full="\
"sf probe; "\
"sf erase 0x0 0x800000; "\
"load mmc 1 ${loadaddr} spiboot.img; "\
"sf write ${loadaddr} 0x0 ${filesize}\0"\
"booting_from_spi="\
"hdmitx edid; "\
"setenv bootargs ${initargs} console=tty0 logo=osd0,loaded,0x3d800000 osd_reverse=0 video_reverse=0; "\
"setenv bootargs ${bootargs} vout=${vout} hdmimode=${hdmimode} modeline=${modeline} voutmode=${voutmode}; "\
"osd open; "\
"osd clear; "\
"vout output ${outputmode}; "\
"run set_spi_params; "\
"load mmc 1 ${preloadaddr} spiboot.img; "\
"sf update ${preloadaddr} 0 ${filesize}\0"\
"boot_spi="\
"sf probe; "\
"sf read ${preloadaddr} ${start_kernel} ${size_kernel}; "\
"sf read ${initrd_high} ${start_initrd} ${size_initrd}; "\
"sf read ${dtb_mem_addr} ${start_dtb} ${size_dtb}; "\
"sf read ${preloadaddr} ${bios_offset_kernel} ${bios_sizeof_kernel}; "\
"sf read ${ramdisk_addr_r} ${bios_offset_initrd} ${bios_sizeof_initrd}; "\
"sf read ${fdt_addr_r} ${bios_offset_dtb} ${bios_sizeof_dtb}; "\
"if test -e mmc 1:1 spiboot.img; then " \
"fdt addr ${dtb_mem_addr}; " \
"fdt addr ${fdt_addr_r}; " \
"fdt resize; " \
"fdt set /emmc@ffe07000 status 'disabled'; " \
"fdt set /soc/cbus/spifc@14000 status 'okay'; " \
"fi; " \
"bootm ${preloadaddr} ${initrd_high} ${dtb_mem_addr};\0"\
"setenv voutmode hdmi; "\
"osd open; osd clear; vout output ${outputmode}; "\
"setenv bootargs ${initargs} console=tty0 logo=osd0,loaded,0x3d800000 osd_reverse=0 video_reverse=0 "\
"hdmimode=${hdmimode} voutmode=${voutmode}; "\
"bootm ${preloadaddr} ${ramdisk_addr_r} ${fdt_addr_r};\0"

#define CONFIG_PREBOOT \
"run switch_bootmode;"
@@ -470,6 +506,7 @@
#define CONFIG_FS_EXT4 1
#define CONFIG_LZO 1
#define CONFIG_FAT_WRITE 1
#define CONFIG_EXT4_WRITE 1

/* Cache Definitions */
//#define CONFIG_SYS_DCACHE_OFF
ProTip! Use n and p to navigate between commits in a pull request.