diff --git a/board/nm/nmhw21/board.c b/board/nm/nmhw21/board.c index 129c1792fc..a348e7a01e 100644 --- a/board/nm/nmhw21/board.c +++ b/board/nm/nmhw21/board.c @@ -433,6 +433,61 @@ static void init_pmic_spl(void) da9063_release_i2c_bus(bus); } +struct reset_registers { + uint32_t value; + uint32_t value_crc; +}; + +#ifdef CONFIG_NRSW_BUILD + +static uint32_t ether_crc(size_t len, uint8_t const *p) +{ + uint32_t crc; + unsigned i; + + crc = ~0; + while (len--) { + crc ^= *p++; + for (i = 0; i < 8; i++) + crc = (crc >> 1) ^ ((crc & 1) ? 0xedb88320 : 0); + } + + /* an reverse the bits, cuz of way they arrive -- last-first */ + crc = (crc >> 16) | (crc << 16); + crc = (crc >> 8 & 0x00ff00ff) | (crc << 8 & 0xff00ff00); + crc = (crc >> 4 & 0x0f0f0f0f) | (crc << 4 & 0xf0f0f0f0); + crc = (crc >> 2 & 0x33333333) | (crc << 2 & 0xcccccccc); + crc = (crc >> 1 & 0x55555555) | (crc << 1 & 0xaaaaaaaa); + + return crc; +} + +void check_pmic_reset_reason(unsigned int reset_reason_shm_location) +{ + volatile struct reset_registers* reset_regs = (struct reset_registers*)reset_reason_shm_location; + uint8_t state = 0x00; + int bus; + int ret; + + bus = da9063_claim_i2c_bus(); + + ret = da9063_get_reg(PMIC_REG_FAULT_LOG, &state); + if ((ret == 0) && (state != 0)) { + if (state & PMIC_FAULT_TWD_ERROR_MASK) { + reset_regs->value = EXTERNAL_WATCHDOG_PATTERN; + reset_regs->value_crc = ether_crc(sizeof(reset_regs->value), + (const uint8_t*)&(reset_regs->value)); + } + + /* clear pmic fault log by writing back all bits currently set */ + da9063_set_reg(PMIC_REG_FAULT_LOG, state); + } + + da9063_release_i2c_bus(bus); +} + +#endif + void am33xx_spl_board_init(void) { /* Set CPU speed to 600 MHz (fix) */ @@ -454,6 +509,10 @@ void am33xx_spl_board_init(void) /* Set MPU Frequency to what we detected now that voltages are set */ do_setup_dpll(&dpll_mpu_regs, &dpll_mpu_opp100); +#ifdef CONFIG_NRSW_BUILD + check_pmic_reset_reason(RESET_REASON_SHM_LOCATION); +#endif + /* Debugger can place marker at end of SRAM to stop boot here */ if (is_jtag_boot(CONFIG_JTAG_MARKER_SPL)) { diff --git a/board/nm/nrhw20/board.c b/board/nm/nrhw20/board.c index 9df873cacd..6b9e646373 100644 --- a/board/nm/nrhw20/board.c +++ b/board/nm/nrhw20/board.c @@ -390,9 +390,10 @@ static void init_pmic_spl(void) (void)da9063_set_reg(PMIC_REG_BUCK_ILIM_B, 0x50); (void)da9063_set_reg(PMIC_REG_BUCK_ILIM_C, 0xFF); - /* TODO: C comments, not C++ */ - // FB 57727 Use synchronous mode for buck converters - // This solves the occasional rail lock up problem + /* + * FB 57727 Use synchronous mode for buck converters + * This solves the occasional rail lock up problem + */ (void)da9063_set_reg(PMIC_REG_BCORE1_CONF, 0x81); (void)da9063_set_reg(PMIC_REG_BCORE2_CONF, 0x81); (void)da9063_set_reg(PMIC_REG_BIO_CONF, 0x81); @@ -400,8 +401,7 @@ static void init_pmic_spl(void) (void)da9063_set_reg(PMIC_REG_BPERI_CONF, 0x81); /* Enable charging of RTC backup capacitor (1mA, 3.1V) */ - (void)da9063_set_reg(PMIC_REG_BBAT_CONT, 0xCF); - /* TODO: Check documentation 1 mA correct ? */ + (void)da9063_set_reg(PMIC_REG_BBAT_CONT, 0xAF); da9063_release_i2c_bus(bus); } @@ -411,7 +411,7 @@ struct reset_registers { uint32_t value_crc; }; -#ifdef CONFIG_NRSW +#ifdef CONFIG_NRSW_BUILD /* TODO: Move ethernet crc to dedicated file */ static uint32_t ether_crc(size_t len, uint8_t const *p) @@ -485,7 +485,7 @@ void am33xx_spl_board_init(void) /* Set MPU Frequency to what we detected now that voltages are set */ do_setup_dpll(&dpll_mpu_regs, &dpll_mpu_opp100); -#ifdef CONFIG_NRSW +#ifdef CONFIG_NRSW_BUILD /* TODO: Move to board_late_init? It is not urgent to have this in SPL. */ check_pmic_reset_reason(RESET_REASON_SHM_LOCATION); #endif @@ -622,18 +622,38 @@ static void init_pcie_slot(void) static void init_gsm(void) { - /* TODO: Check and update for Toby-L2 */ /* - * Perform power up sequence for Huawei ME909s. - * - * Modem is initially disabled and does not start automatically. - * Enable power and start modem by "pressing" POWER_ON_OFF input for 1.0s. - * + * Perform power up sequence for TOBY-L2 modem. + * + * TOBY-L2 series can be switched on in one of the following ways: + * - Rising edge on the VCC pin to a valid voltage for module supply, + * i.e. applying module supply + * - Low level on the PWR_ON pin, which is normally set high by an + * internal pull-up, for a valid time period when the applied VCC + * voltage is within the valid operating range (see section 4.2.8). + * - Low level on the RESET_N pin, which is normally set high by an + * internal pull-up, for a valid time period when the applied VCC + * voltage is within the valid operating range (see section 4.2.9). + * + * PWR_ON low time: 5 ms - Low time to switch-on the module + * RESET_N low time: 18..800 ms - Low time to switch-on the module + * 2.1..15 s - Low time to reset the module + * 16 s - Low time to switch-off the module + * * References: - * - HUAWEI ME909s Series LTE LGA Module Hardware Guide, Issue 02, Date 2016-02-20 - * 3.3.2 Power Supply VBAT Interface - * 3.4.2 Power-on/off Pin, Figure 3.7 + * - uBlox TOBY-L2 Datasheet UBX-13004573 - R24 + * 2.3.1 Module power-on + * 4.2.8 PWR_ON pin + * 4.2.9 RESET_N pin + * + * Functionality: + * - Leave GSM power enable as is (default at power up = off) + * - Set reset line inactive (note: inverter logic in HW present) + * - Leave button unpressed (note: inverter logic in HW present) + * - Modem shall be enabled by Linux system by enabling GSM power + * supply */ + int bus; puts("GSM: "); @@ -794,7 +814,7 @@ static void get_variant_name(void) static void get_hw_version(void) { -#ifdef CONFIG_NRSW +#ifdef CONFIG_NRSW_BUILD char hw_versions[16]; char new_env[256]; /* current bootargs = 84 bytes */ #endif @@ -804,8 +824,7 @@ static void get_hw_version(void) printf("HW20: V%d.%d\n", hw_ver, hw_rev); - /* TODO: Check if this can be removed eventually */ -#ifdef CONFIG_NRSW +#ifdef CONFIG_NRSW_BUILD /* add hardware versions to environment */ snprintf(hw_versions, sizeof(hw_versions), "CP=%d.%d", hw_ver, hw_rev); snprintf(new_env, sizeof(new_env), "setenv bootargs $bootargs %s", hw_versions); @@ -1076,6 +1095,7 @@ int board_late_init(void) set_console(); shield_init(); + /* TODO: Check, correct? */ set_status_led(0, 1); /* Green */ set_indicator(0, 0, 1); /* Green */ @@ -1223,46 +1243,75 @@ static void ft_enable_node(void* blob, const char* name) } } -static void ft_dio(void *blob, int shield_type) +/* + * Modify the name of a gpio in a gpio-line-names string list. + */ +static void ft_set_gpio_name(void *blob, const char* gpio, int pin, const char* name) { - switch (shield_type) { - /* If COM/IO shield is present enable its I/Os */ - case SHIELD_COM_IO: - ft_enable_node(blob, "/netbox_dio_comio"); - break; + int node_ofs = fdt_path_offset(blob, gpio); + if (node_ofs != -1) { + const struct fdt_property* prop = fdt_get_property(blob, node_ofs, "gpio-line-names", NULL); + if (prop != NULL) { + const char* text; + int pos = 0; + int i; + char buffer[512]; - default: - ft_enable_node(blob, "/netbox_dio_default"); - break; + for (i=0; i<32; i++) { + if (i == pin) { + /* Take provided name if GPIO pin is matched */ + text = name; + } + else { + /* Take existing name from strin list */ + (void)fdt_get_string_index(blob, node_ofs, "gpio-line-names", i, &text); + } + /* Add name to new string list */ + strncpy(buffer+pos, text, sizeof(buffer)-pos); + pos += strlen(text) + 1; + } + + (void)fdt_setprop(blob, node_ofs, "gpio-line-names", buffer, pos); + } } } -static void ft_serial(void *blob, int shield_type) +/* + * Enable digital IOs provided by COM/IO shield in gpio nodes + */ +static void ft_comio_gpios(void *blob) { - switch (shield_type) { - /* Enable uart1 (ttyS0) always as kernel needs it as fallback - console, if (ttyS1) is not available as console. */ + /* gpio0_7: COM/IO relay output */ + ft_set_gpio_name(blob, "/ocp/gpio@44e07000", 7, "COMIO_OUT0"); - default: + /* gpio1_8: COM/IO digital input */ + ft_set_gpio_name(blob, "/ocp/gpio@4804c000", 8, "COMIO_IN0"); +} + +static void ft_shields(void* blob) +{ + int shield_type = -1; + + shield_type = bd_get_shield(0); + switch (shield_type) { + case SHIELD_COM_IO: + ft_comio_gpios(blob); + ft_enable_node(blob, "/netbox_dio_comio"); /* TODO: Should use alias serial0 */ ft_enable_node(blob, "/ocp/serial@44e09000"); break; - } -} -static void ft_dcan(void *blob, int shield_type) -{ - switch (shield_type) { - /* If Dual CAN shield is present enable dcan0, dcan1N1 */ case SHIELD_DUALCAN: - /* TODO: Should use alias d_can0, d_can1 */ + /* TODO: Should use alias d_can0, d_can1 */ ft_enable_node(blob, "/ocp/can@481cc000"); ft_enable_node(blob, "/ocp/can@481d0000"); break; default: + ft_enable_node(blob, "/netbox_dio_default"); break; - } + }; + } static void ft_bootloader_version(void *blob) @@ -1292,18 +1341,11 @@ static void ft_hw_info(void *blob) int ft_board_setup(void *blob, bd_t *bd) { - /* TODO: Rework to behave like HW24, once this one is finalized */ - /* ft_shields() function with switch case for shields */ - int shield_type = -1; - ft_bootloader_version(blob); ft_hw_info(blob); - shield_type = bd_get_shield(0); + ft_shields(blob); - ft_dio(blob, shield_type); - ft_serial(blob, shield_type); - ft_dcan(blob, shield_type); return 0; } diff --git a/board/nm/nrhw20/board.h b/board/nm/nrhw20/board.h index eb71c2d809..ba3a2feca3 100644 --- a/board/nm/nrhw20/board.h +++ b/board/nm/nrhw20/board.h @@ -21,9 +21,6 @@ void enable_uart0_pin_mux(void); void disable_uart0_pin_mux(void); void enable_uart1_pin_mux(void); -/* TODO: Remove */ -/*void enable_uart5_pin_mux(void);*/ - void enable_board_pin_mux(void); #define GPIO_TO_PIN(bank, gpio) (32 * (bank) + (gpio)) diff --git a/board/nm/nrhw20/mux.c b/board/nm/nrhw20/mux.c index aff33738bd..eeea92ab56 100644 --- a/board/nm/nrhw20/mux.c +++ b/board/nm/nrhw20/mux.c @@ -250,11 +250,3 @@ void enable_uart1_pin_mux(void) { configure_module_pin_mux(uart1_pin_mux); } - -/* TODO: Remove */ -/* -void enable_uart5_pin_mux(void) -{ - configure_module_pin_mux(uart5_pin_mux); -} -*/ diff --git a/board/nm/nrhw24/board.c b/board/nm/nrhw24/board.c index ff10fe8582..9200eb5256 100644 --- a/board/nm/nrhw24/board.c +++ b/board/nm/nrhw24/board.c @@ -348,7 +348,7 @@ struct reset_registers { uint32_t value_crc; }; -#ifdef CONFIG_NRSW +#ifdef CONFIG_NRSW_BUILD /* TODO: Move ethernet crc to dedicated file */ static uint32_t ether_crc(size_t len, uint8_t const *p) @@ -420,7 +420,7 @@ void am33xx_spl_board_init(void) /* Set MPU Frequency to what we detected now that voltages are set */ do_setup_dpll(&dpll_mpu_regs, &dpll_mpu_opp100); -#ifdef CONFIG_NRSW +#ifdef CONFIG_NRSW_BUILD /* TODO: Move to board_late_init? It is not urgent to have this in SPL. */ check_pmic_reset_reason(RESET_REASON_SHM_LOCATION); #endif @@ -715,7 +715,7 @@ static void get_variant_name(void) static void get_hw_version(void) { -#ifdef CONFIG_NRSW +#ifdef CONFIG_NRSW_BUILD char hw_versions[16]; char new_env[256]; /* current bootargs = 84 bytes */ #endif @@ -725,7 +725,7 @@ static void get_hw_version(void) printf("HW24: V%d.%d\n", hw_ver, hw_rev); -#ifdef CONFIG_NRSW +#ifdef CONFIG_NRSW_BUILD /* add hardware versions to environment */ snprintf(hw_versions, sizeof(hw_versions), "CP=%d.%d", hw_ver, hw_rev); snprintf(new_env, sizeof(new_env), "setenv bootargs $bootargs %s", hw_versions); @@ -1240,6 +1240,36 @@ static void ft_hw_info(void *blob) } } +static void ft_override_thermal(void *blob) +{ + const char* temp_alert0 = getenv("temp_alert0"); + if (temp_alert0 != NULL) { + int node_ofs = -1; + int temp_in_degs = 0; + + temp_in_degs = simple_strtoul(temp_alert0, NULL, 10); + if (temp_in_degs == 0) { + temp_in_degs = 95; + } else if (temp_in_degs < 20) { + temp_in_degs = 20; + } else if (temp_in_degs > 120) { + temp_in_degs = 120; + } + + printf("WARNING: Overriding CPU thermal alert to %d°C, critical to 125°C\n", temp_in_degs); + + node_ofs = fdt_path_offset(blob, "/thermal-zones/cpu-thermal/trips/cpu-alert0"); + if (node_ofs >= 0) { + fdt_setprop_inplace_u32(blob, node_ofs, "temperature", temp_in_degs*1000); + } + + node_ofs = fdt_path_offset(blob, "/thermal-zones/cpu-thermal/trips/cpu-crit"); + if (node_ofs >= 0) { + fdt_setprop_inplace_u32(blob, node_ofs, "temperature", 125*1000); + } + } +} + int ft_board_setup(void *blob, bd_t *bd) { ft_bootloader_version(blob); @@ -1256,6 +1286,8 @@ int ft_board_setup(void *blob, bd_t *bd) */ /* ft_enable_node(blob, "/ocp/serial@44e09000"); */ + ft_override_thermal(blob); + return 0; } diff --git a/include/configs/am335x_nmhw21.h b/include/configs/am335x_nmhw21.h index de3df92d38..f596c955a2 100644 --- a/include/configs/am335x_nmhw21.h +++ b/include/configs/am335x_nmhw21.h @@ -63,70 +63,112 @@ int eth_phy_timeout(void); #ifndef CONFIG_SPL_BUILD - /* * Memory map for booting Linux * - * 0x80000000 63MB KERNEL_ADDR (kernel_addr), kernel execution address - * 0x83F00000 1MB FDT_ADDR (fdt_addr_r), device tree loading address if not included in kernel - * 0x84000000 126MB RD_ADDR (ramdisk_addr_r), ramdisc loading address - * 0x8BE00000 2MB PXE_ADDR (pxefile_addr_r), pxe configuration file (pxe get command) - * 0x8C000000 1MB LOAD_ADDR (load_addr), loading address for generic files - * 0x8C100000 63MB KERNEL_ADDR_R (kernel_addr_r), kernel loading address (will be relocated to kernel_addr) - * 0x90000000 256MB <>, Free space 512MB systems + * 0x80000000 32MB KERNEL_ADDR (kernel_addr), kernel execution address + * 0x82000000 190MB KERNEL_ADDR_R (kernel_addr_r), FIT image/kernel loading address + * kernel will be relocated kernel_addr + * for FIT images, ramdisc and dtb will be relocated to + * top of bootmemory (0x8e000000 downwards) + * 0x8BE00000 1MB FDT_ADDR_R (fdt_addr_r), device tree if separate from kernel/FIT + * 0x8BF00000 1MB PXE_ADDR (pxefile_addr_r), pxe configuration file (pxe get command) + * 0x8C000000 32MB LOAD_ADDR (load_addr), loading address for generic files + * + * 0x8E000000 4B NRSW reset reason + * 32MB <>, Free space + * 0x90000000 256MB <>, Free space, 512MB systems * 0xA0000000 512MB <>, Free space, 1GB systems only * 0xC0000000 End of RAM */ #define KERNEL_ADDR "0x80000000" -#define FDT_ADDR "0x83F00000" -#define RD_ADDR "0x84000000" -#define PXE_ADDR "0x8BE00000" +#define KERNEL_ADDR_R "0x82000000" +#define FDT_ADDR_R "0x8BE00000" +#define PXE_ADDR "0x8BF00000" #define LOAD_ADDR "0x8C000000" -#define KERNEL_ADDR_R "0x8C100000" /* - * Avoid copying ramdisc and dtb above 512MB, as it breaks Linux boot. - * -1 means "do not copy" to high address, use in place. + * Limit boot memory to 256 MBytes to comply with kernel initial memory layout + * This is the official way to restrict image load addresses. + * Don't use xx_high_addr variables. */ -#define INITRD_HIGH_ADDR "0x84000000" -#define FDT_HIGH_ADDR "0xffffffff" +#define BOOTM_SIZE "0x0E000000" + +/* Set boot command depending of software environment */ +#ifndef CONFIG_NRSW_BUILD +/* Yocto/OSTree boot command */ +#define MAIN_BOOTCMD "run boot_ostree" +#else +/* NRSW boot command */ +#define MAIN_BOOTCMD "run sdboot" +#endif #define CONFIG_EXTRA_ENV_SETTINGS \ - "fdt_image=am335x-nmhw21-prod1.dtb\0" \ - "fdt_addr_r=" FDT_ADDR "\0" \ - "fdt_high=" FDT_HIGH_ADDR "\0" \ - "initrd_high=" INITRD_HIGH_ADDR "\0" \ - "kernel_addr=" KERNEL_ADDR "\0" \ + /* Memory Adresses */ \ + "fdt_addr_r=" FDT_ADDR_R "\0" \ + "kernel_addr=" KERNEL_ADDR "\0" /* NRSW only */ \ "kernel_addr_r=" KERNEL_ADDR_R "\0" \ "load_addr=" LOAD_ADDR "\0" \ "pxefile_addr_r=" PXE_ADDR "\0" \ - "ramdisk_addr_r=" RD_ADDR "\0" \ + "bootm_size=" BOOTM_SIZE "\0" \ + \ + /* Misc */ \ "defaultconsole=ttyS2\0" \ "fdt_skip_update=yes\0" \ + "bootdelay=0\0" \ + \ + /* Networking */ \ "ethprime=cpsw\0" \ "ethopts=ti_cpsw.rx_packet_max=1526\0" \ + "ipaddr=192.168.1.1\0" \ + "serverip=192.168.1.254\0" \ + "tftptimeout=2000\0" \ + "tftptimeoutcountmax=5\0" \ + "bootpretryperiod=10000\0" /* 2000 */ \ + "autoload=false\0" \ + \ + /* OSTree boot */ \ "bootcmd_otenv=ext4load mmc 1:1 $load_addr /boot/loader/uEnv.txt; " \ "setenv bootargs_prev $bootargs; " \ "env import -t $load_addr $filesize; setenv bootargs $bootargs_prev $bootargs root=/dev/ram0 console=$defaultconsole,115200 " \ "$ethopts rw ostree_root=/dev/mmcblk1p1\0" \ "bootcmd_rd_in_mmc=ext4load mmc 1:1 $kernel_addr_r /boot$kernel_image; " \ "bootm $kernel_addr_r\0" \ - "bootcmd=run bootcmd_otenv; run bootcmd_rd_in_mmc\0" \ - "bootdelay=0\0" \ - "ipaddr=192.168.1.1\0" \ - "serverip=192.168.1.254\0" \ - "tftptimeout=2000\0" \ - "tftptimeoutcountmax=5\0" \ - "bootpretryperiod=10000\0" \ - "autoload=false\0" \ - "tftp_recovery=tftpboot $kernel_addr recovery-image; tftpboot $fdt_addr_r recovery-dtb; " \ - "setenv bootargs rdinit=/etc/preinit console=$defaultconsole,115200 " \ - "debug ethopts; " \ - "bootz $kernel_addr - $fdt_addr_r\0" \ - "pxe_recovery=mdio up $ethprime && dhcp && pxe get && pxe boot\0" \ + "boot_ostree=run bootcmd_otenv; run bootcmd_rd_in_mmc\0" \ + \ + /* NRSW boot */ \ + "root_part=1\0" /* from NRSW, required here? set from board.c */ \ + "kernel_image=kernel.bin\0" \ + "fdt_image=am335x-nmhw24-prod1.dtb\0" /* diff, openwrt-nrhw24-nb801.dtb, not relevant as it will be overwritten */ \ + "add_sd_bootargs=setenv bootargs $bootargs root=/dev/${mmc_dev}p$root_part rootfstype=ext4 " \ + "console=$defaultconsole,115200 rootwait loglevel=4 ti_cpsw.rx_packet_max=1526\0" \ + "add_version_bootargs=setenv bootargs $bootargs\0" \ + "sdbringup=echo Try bringup boot && ext4load mmc 1:$root_part $kernel_addr /boot/zImage && " \ + "ext4load mmc 1:$root_part $fdt_addr /boot/$fdt_image && setenv bootargs $bootargs rw;\0" \ + "sdprod=ext4load mmc 1:$root_part $kernel_addr /boot/$kernel_image && " \ + "ext4load mmc 1:$root_part $fdt_addr /boot/$fdt_image && setenv bootargs $bootargs ro;\0" \ + "sdboot=env set fdt_addr " FDT_ADDR_R "; "\ + "if mmc dev 1; then echo Copying Linux from SD to RAM...; "\ + "if test -e mmc 1:$root_part /boot/$kernel_image; then run sdprod; " \ + "else run sdbringup; fi; " \ + /* For v4.19 kernel $mmc_dev should be "mmcblk1" (read from DT), for v3.18 kernel: "mmcblk0" */ \ + "fdt addr $fdt_addr;if fdt get value mmc_dev /nm_env nm,mmc-dev;then;else setenv mmc_dev mmcblk0;fi;" \ + "run add_sd_bootargs; run add_version_bootargs; " \ + "bootz $kernel_addr - $fdt_addr; fi\0" \ + \ + /* Boot command */ \ + "bootcmd=" MAIN_BOOTCMD "\0" \ + \ + /* Recovery boot (same for OSTree and NRSW) */ \ "recovery=run pxe_recovery || setenv ipaddr $ipaddr; setenv serverip $serverip; run tftp_recovery\0" \ - /* setenv ipaddr and serverip is necessary, because dhclient can destroy the IPs internally */ + /* setenv ipaddr and serverip is necessary, because dhclient destroys the IPs internally */ \ + "pxe_recovery=mdio up $ethprime && dhcp && pxe get && pxe boot\0" \ + "tftp_recovery=tftpboot $kernel_addr_r recovery-image; tftpboot $fdt_addr_r recovery-dtb; " \ + "setenv bootargs rdinit=/etc/preinit console=$defaultconsole,115200 " \ + "debug $ethopts; " \ + "bootz $kernel_addr_r - $fdt_addr_r\0" /* kernel_addr_r */ + #endif #define CONFIG_ZERO_BOOTDELAY_CHECK @@ -234,6 +276,18 @@ int eth_phy_timeout(void); #define CONFIG_SYS_MEMTEST_START 0x84000000 #define CONFIG_SYS_MEMTEST_END 0x87900000 + +#ifdef CONFIG_NRSW_BUILD +/* support for NM packed bootloader */ +#define CONFIG_NM_BOOTLOADER_FORMAT + +/* password protected login */ +#define CONFIG_CRYPT +#define CONFIG_NM_LOGIN +#define CONFIG_NM_LOGIN_PART "1:3" /* TODO: Define location of file for OSTree/Yocto */ +#define CONFIG_NM_LOGIN_PASSWD "/root/boot/bootpass" +#endif + #define CONFIG_CMD_PXE #define CONFIG_OF_BOARD_SETUP @@ -241,6 +295,13 @@ int eth_phy_timeout(void); #define CONFIG_JTAG_MARKER_SPL 0x402FFF00 #define CONFIG_JTAG_MARKER_UBOOT 0x807FFF00 +/* NRSW PMIC Reset Reason */ +#ifdef CONFIG_NRSW_BUILD +#define RESET_REASON_SHM_LOCATION 0x8e000000 +#define EXTERNAL_WATCHDOG_PATTERN 0x781f9ce2 +#endif + + /* SPL command is not needed */ #undef CONFIG_CMD_SPL diff --git a/include/configs/am335x_nrhw20.h b/include/configs/am335x_nrhw20.h index 77e09e5dfb..66109b5717 100644 --- a/include/configs/am335x_nrhw20.h +++ b/include/configs/am335x_nrhw20.h @@ -19,11 +19,6 @@ #include -/* TODO: Inject via build system */ -#define CONFIG_NRSW - - - /* Disable U-Boot load from filesystems, to save around 10 kB SPL image size */ #ifdef CONFIG_SYS_MMCSD_FS_BOOT_PARTITION # undef CONFIG_SYS_MMCSD_FS_BOOT_PARTITION @@ -77,48 +72,45 @@ int eth_phy_timeout(void); #ifndef CONFIG_SPL_BUILD - /* * Memory map for booting Linux * - * 0x80000000 63MB KERNEL_ADDR (kernel_addr), kernel execution address - * 0x83F00000 1MB FDT_ADDR_R (fdt_addr_r), device tree loading address if not included in kernel - * 126MB INIT_RD_HIGH (initrd_high), ramdisc top address for relocation - * 0x8BE00000 2MB PXE_ADDR (pxefile_addr_r), pxe configuration file (pxe get command) - * 0x8C000000 1MB LOAD_ADDR (load_addr), loading address for generic files - * 0x8C100000 31MB KERNEL_ADDR_R (kernel_addr_r), kernel loading address (will be relocated to kernel_addr) + * 0x80000000 32MB KERNEL_ADDR (kernel_addr), kernel execution address + * 0x82000000 190MB KERNEL_ADDR_R (kernel_addr_r), FIT image/kernel loading address + * kernel will be relocated kernel_addr + * for FIT images, ramdisc and dtb will be relocated to + * top of bootmemory (0x8e000000 downwards) + * 0x8BE00000 1MB FDT_ADDR_R (fdt_addr_r), device tree if separate from kernel/FIT + * 0x8BF00000 1MB PXE_ADDR (pxefile_addr_r), pxe configuration file (pxe get command) + * 0x8C000000 32MB LOAD_ADDR (load_addr), loading address for generic files + * * 0x8E000000 4B NRSW reset reason - * 0x90000000 256MB <>, Free space 512MB systems + * 32MB <>, Free space + * 0x90000000 256MB <>, Free space, 512MB systems * 0xA0000000 512MB <>, Free space, 1GB systems only * 0xC0000000 End of RAM - * - * ((0x84000000 126MB RD_ADDR (ramdisk_addr_r), ramdisc loading address)) */ #define KERNEL_ADDR "0x80000000" -/*#define FDT_ADDR "0x82000000" */ /* NRSW, trying to use FDT_ADDR_R = 0x83F00000 instead */ -#define FDT_ADDR_R "0x83F00000" -#define PXE_ADDR "0x8BE00000" +#define KERNEL_ADDR_R "0x82000000" +#define FDT_ADDR_R "0x8BE00000" +#define PXE_ADDR "0x8BF00000" #define LOAD_ADDR "0x8C000000" -#define KERNEL_ADDR_R "0x8C100000" -/* TODO: Check this with 1 GByte system */ -/* Most likely ramdisk and FDT will be loaded to too high adresses and boot will fail */ -#if 0 /* - * Avoid copying ramdisc and dtb above 512MB, as it breaks Linux boot. - * -1 means "do not copy" to high address, use in place. + * Limit boot memory to 256 MBytes to comply with kernel initial memory layout + * This is the official way to restrict image load addresses. + * Don't use xx_high_addr variables. */ -#define INITRD_HIGH_ADDR "0x8BE0000" -#define RD_ADDR "0x84000000" -#define FDT_HIGH_ADDR "0x87000000" -#define FDT_HIGH_ADDR "0xffffffff" - - "fdt_high=" FDT_HIGH_ADDR "\0" /* Breaks NRSW, required by Yocto ! */ \ - "fdt_addr=" FDT_ADDR "\0" /* NRSW only, breaks yocto, can we move that to fdt_addr_r ? */ \ - "initrd_high=" INITRD_HIGH_ADDR "\0" /* (0x84000000) -> INIT_RD_ADDR (0x88000000) */ \ - "ramdisk_addr_r=" RD_ADDR "\0" \ +#define BOOTM_SIZE "0x0E000000" +/* Set boot command depending of software environment */ +#ifndef CONFIG_NRSW_BUILD +/* Yocto/OSTree boot command */ +#define MAIN_BOOTCMD "run boot_ostree" +#else +/* NRSW boot command */ +#define MAIN_BOOTCMD "run sdboot" #endif #define CONFIG_EXTRA_ENV_SETTINGS \ @@ -128,6 +120,7 @@ int eth_phy_timeout(void); "kernel_addr_r=" KERNEL_ADDR_R "\0" \ "load_addr=" LOAD_ADDR "\0" \ "pxefile_addr_r=" PXE_ADDR "\0" \ + "bootm_size=" BOOTM_SIZE "\0" \ \ /* Misc */ \ "defaultconsole=ttyS1\0" \ @@ -147,12 +140,11 @@ int eth_phy_timeout(void); /* OSTree boot */ \ "bootcmd_otenv=ext4load mmc 1:1 $load_addr /boot/loader/uEnv.txt; " \ "setenv bootargs_prev $bootargs; " \ - "env import -t $load_addr $filesize; " \ - "setenv bootargs $bootargs_prev $bootargs root=/dev/ram0 console=$defaultconsole,115200 " \ + "env import -t $load_addr $filesize; setenv bootargs $bootargs_prev $bootargs root=/dev/ram0 console=$defaultconsole,115200 " \ "$ethopts rw ostree_root=/dev/mmcblk1p1\0" \ "bootcmd_rd_in_mmc=ext4load mmc 1:1 $kernel_addr_r /boot$kernel_image; " \ "bootm $kernel_addr_r\0" \ - "bootcmd=run shieldcmd; run bootcmd_otenv; run bootcmd_rd_in_mmc\0" \ + "boot_ostree=run shieldcmd; run bootcmd_otenv; run bootcmd_rd_in_mmc\0" \ \ /* NRSW boot */ \ "root_part=1\0" /* from NRSW, required here? set from board.c */ \ @@ -173,85 +165,21 @@ int eth_phy_timeout(void); "fdt addr $fdt_addr;if fdt get value mmc_dev /nm_env nm,mmc-dev;then;else setenv mmc_dev mmcblk0;fi;" \ "run add_sd_bootargs; run add_version_bootargs; run shieldcmd; " \ "bootz $kernel_addr - $fdt_addr; fi\0" \ - /* "bootcmd=run sdboot\0" */ \ \ - /* Recovery boot */ \ + /* Boot command */ \ + "bootcmd=" MAIN_BOOTCMD "\0" \ + \ + /* Recovery boot (same for OSTree and NRSW) */ \ "recovery=run pxe_recovery || setenv ipaddr $ipaddr; setenv serverip $serverip; run tftp_recovery\0" \ - /* setenv ipaddr and serverip is necessary, because dhclient can destroy the IPs internally */ \ + /* setenv ipaddr and serverip is necessary, because dhclient destroys the IPs internally */ \ "pxe_recovery=mdio up $ethprime && dhcp && pxe get && pxe boot\0" \ - "tftp_recovery=tftpboot $kernel_addr_r recovery-image; tftpboot $fdt_addr_r recovery-dtb; " /* kernel_addr_r ? */ \ + "tftp_recovery=tftpboot $kernel_addr_r recovery-image; tftpboot $fdt_addr_r recovery-dtb; " \ "setenv bootargs rdinit=/etc/preinit console=$defaultconsole,115200 " \ "debug $ethopts; " \ "bootz $kernel_addr_r - $fdt_addr_r\0" /* kernel_addr_r */ #endif -#if 0 - -#ifndef CONFIG_SPL_BUILD -#define KERNEL_ADDR "0x80000000" -#define LOAD_ADDR "0x83000000" -#define FDT_ADDR "0x82000000" -#define PXE_ADDR "0x82800000" -#define FDT_HIGH_ADDR "0x87000000" -#define INIT_RD_ADDR "0x88000000" - -#define CONFIG_EXTRA_ENV_SETTINGS \ - "kernel_image=kernel.bin\0" \ - "fdt_image=openwrt-nrhw20-nb1601.dtb\0"\ - "modeboot=sdboot\0" \ - "fdt_addr=" FDT_ADDR "\0" \ - "kernel_addr=" KERNEL_ADDR "\0" \ - "load_addr=" LOAD_ADDR "\0" \ - "root_part=1\0" /* Default root partition, overwritten in board file */ \ - "defaultconsole=ttyS1\0" /* Default output console */ \ - "add_sd_bootargs=setenv bootargs $bootargs root=/dev/mmcblk1p$root_part rootfstype=ext4 " \ - "console=$defaultconsole,115200 rootwait loglevel=4 ti_cpsw.rx_packet_max=1526\0" \ - "add_version_bootargs=setenv bootargs $bootargs\0" \ - "fdt_skip_update=yes\0" \ - "ethprime=cpsw\0" \ - "sdbringup=echo Try bringup boot && ext4load mmc 1:$root_part $kernel_addr /boot/zImage && " \ - "ext4load mmc 1:$root_part $fdt_addr /boot/$fdt_image && setenv bootargs $bootargs rw;\0" \ - "sdprod=ext4load mmc 1:$root_part $kernel_addr /boot/$kernel_image && " \ - "ext4load mmc 1:$root_part $fdt_addr /boot/$fdt_image && setenv bootargs $bootargs ro;\0" \ - "sdboot=if mmc dev 1; then echo Copying Linux from SD to RAM...; "\ - "if test -e mmc 1:$root_part /boot/$kernel_image; then run sdprod; " \ - "else run sdbringup; fi; " \ - "run add_sd_bootargs; run add_version_bootargs; run shieldcmd; " \ - "bootz $kernel_addr - $fdt_addr; fi\0" \ - "bootcmd_otenv=ext4load mmc 1:1 $load_addr /boot/loader/uEnv.txt; " \ - "setenv bootargs_prev $bootargs; " \ - "env import -t $load_addr $filesize; " \ - "setenv bootargs $bootargs_prev $bootargs root=/dev/ram0 console=$defaultconsole,115200 " \ - "$ethopts rw ostree_root=/dev/mmcblk1p1\0" \ - "bootcmd_rd_in_mmc=ext4load mmc 1:1 $kernel_addr_r /boot$kernel_image; " \ - "bootm $kernel_addr_r\0" \ - "bootcmd=run bootcmd_otenv; run bootcmd_rd_in_mmc\0" \ - "ipaddr=192.168.1.1\0" \ - "serverip=192.168.1.254\0" \ - "pxefile_addr_r=" PXE_ADDR "\0" \ - "fdt_addr_r=" FDT_ADDR "\0" \ - "fdt_high=" FDT_HIGH_ADDR "\0" \ - "kernel_addr_r=" KERNEL_ADDR "\0" \ - "ramdisk_addr_r=" LOAD_ADDR "\0" \ - "initrd_high=" INIT_RD_ADDR "\0" \ - "bootpretryperiod=1000\0" \ - "tftptimeout=2000\0" \ - "tftptimeoutcountmax=5\0" \ - "bootpretryperiod=2000\0" \ - "autoload=false\0" \ - "shieldcmd=\0" \ - "tftp_recovery=tftpboot $kernel_addr recovery-image; tftpboot $fdt_addr recovery-dtb; " \ - "setenv bootargs rdinit=/etc/preinit console=$defaultconsole,115200 " \ - "debug ti_cpsw.rx_packet_max=1526; run shieldcmd; " \ - "bootz $kernel_addr - $fdt_addr\0" \ - "pxe_recovery=sleep 3 && dhcp && pxe get && pxe boot\0" \ - "recovery=run pxe_recovery || setenv ipaddr $ipaddr; setenv serverip $serverip; run tftp_recovery\0" \ - /* setenv ipaddr and serverip is necessary, because dhclient can destroy the IPs inernally */ -#endif - -#endif - /* TODO: Check if ok for NRSW? */ #define CONFIG_ZERO_BOOTDELAY_CHECK @@ -367,7 +295,7 @@ int eth_phy_timeout(void); #define CONFIG_SYS_MEMTEST_END 0x87900000 -#ifdef CONFIG_NRSW +#ifdef CONFIG_NRSW_BUILD /* support for NM packed bootloader */ #define CONFIG_NM_BOOTLOADER_FORMAT @@ -386,7 +314,7 @@ int eth_phy_timeout(void); #define CONFIG_JTAG_MARKER_UBOOT 0x807FFF00 /* NRSW PMIC Reset Reason */ -#ifdef CONFIG_NRSW +#ifdef CONFIG_NRSW_BUILD #define RESET_REASON_SHM_LOCATION 0x8e000000 #define EXTERNAL_WATCHDOG_PATTERN 0x781f9ce2 #endif diff --git a/include/configs/am335x_nrhw24.h b/include/configs/am335x_nrhw24.h index 1844dd3839..1a0c04b023 100644 --- a/include/configs/am335x_nrhw24.h +++ b/include/configs/am335x_nrhw24.h @@ -19,11 +19,6 @@ #include -/* TODO: Inject via build system */ -#define CONFIG_NRSW - - - /* Disable U-Boot load from filesystems, to save around 10 kB SPL image size */ #ifdef CONFIG_SYS_MMCSD_FS_BOOT_PARTITION # undef CONFIG_SYS_MMCSD_FS_BOOT_PARTITION @@ -75,48 +70,45 @@ int eth_phy_timeout(void); #ifndef CONFIG_SPL_BUILD - /* * Memory map for booting Linux * - * 0x80000000 63MB KERNEL_ADDR (kernel_addr), kernel execution address - * 0x83F00000 1MB FDT_ADDR_R (fdt_addr_r), device tree loading address if not included in kernel - * 126MB INIT_RD_HIGH (initrd_high), ramdisc top address for relocation - * 0x8BE00000 2MB PXE_ADDR (pxefile_addr_r), pxe configuration file (pxe get command) - * 0x8C000000 1MB LOAD_ADDR (load_addr), loading address for generic files - * 0x8C100000 31MB KERNEL_ADDR_R (kernel_addr_r), kernel loading address (will be relocated to kernel_addr) + * 0x80000000 32MB KERNEL_ADDR (kernel_addr), kernel execution address + * 0x82000000 190MB KERNEL_ADDR_R (kernel_addr_r), FIT image/kernel loading address + * kernel will be relocated kernel_addr + * for FIT images, ramdisc and dtb will be relocated to + * top of bootmemory (0x8e000000 downwards) + * 0x8BE00000 1MB FDT_ADDR_R (fdt_addr_r), device tree if separate from kernel/FIT + * 0x8BF00000 1MB PXE_ADDR (pxefile_addr_r), pxe configuration file (pxe get command) + * 0x8C000000 32MB LOAD_ADDR (load_addr), loading address for generic files + * * 0x8E000000 4B NRSW reset reason - * 0x90000000 256MB <>, Free space 512MB systems + * 32MB <>, Free space + * 0x90000000 256MB <>, Free space, 512MB systems * 0xA0000000 512MB <>, Free space, 1GB systems only * 0xC0000000 End of RAM - * - * ((0x84000000 126MB RD_ADDR (ramdisk_addr_r), ramdisc loading address)) */ #define KERNEL_ADDR "0x80000000" -/*#define FDT_ADDR "0x82000000" */ /* NRSW, trying to use FDT_ADDR_R = 0x83F00000 instead */ -#define FDT_ADDR_R "0x83F00000" -#define PXE_ADDR "0x8BE00000" +#define KERNEL_ADDR_R "0x82000000" +#define FDT_ADDR_R "0x8BE00000" +#define PXE_ADDR "0x8BF00000" #define LOAD_ADDR "0x8C000000" -#define KERNEL_ADDR_R "0x8C100000" -/* TODO: Check this with 1 GByte system */ -/* Most likely ramdisk and FDT will be loaded to too high adresses and boot will fail */ -#if 0 /* - * Avoid copying ramdisc and dtb above 512MB, as it breaks Linux boot. - * -1 means "do not copy" to high address, use in place. + * Limit boot memory to 256 MBytes to comply with kernel initial memory layout + * This is the official way to restrict image load addresses. + * Don't use xx_high_addr variables. */ -#define INITRD_HIGH_ADDR "0x8BE0000" -#define RD_ADDR "0x84000000" -#define FDT_HIGH_ADDR "0x87000000" -#define FDT_HIGH_ADDR "0xffffffff" - - "fdt_high=" FDT_HIGH_ADDR "\0" /* Breaks NRSW, required by Yocto ! */ \ - "fdt_addr=" FDT_ADDR "\0" /* NRSW only, breaks yocto, can we move that to fdt_addr_r ? */ \ - "initrd_high=" INITRD_HIGH_ADDR "\0" /* (0x84000000) -> INIT_RD_ADDR (0x88000000) */ \ - "ramdisk_addr_r=" RD_ADDR "\0" \ +#define BOOTM_SIZE "0x0E000000" +/* Set boot command depending of software environment */ +#ifndef CONFIG_NRSW_BUILD +/* Yocto/OSTree boot command */ +#define MAIN_BOOTCMD "run boot_ostree" +#else +/* NRSW boot command */ +#define MAIN_BOOTCMD "run sdboot" #endif #define CONFIG_EXTRA_ENV_SETTINGS \ @@ -126,6 +118,7 @@ int eth_phy_timeout(void); "kernel_addr_r=" KERNEL_ADDR_R "\0" \ "load_addr=" LOAD_ADDR "\0" \ "pxefile_addr_r=" PXE_ADDR "\0" \ + "bootm_size=" BOOTM_SIZE "\0" \ \ /* Misc */ \ "defaultconsole=ttyS1\0" \ @@ -149,7 +142,7 @@ int eth_phy_timeout(void); "$ethopts rw ostree_root=/dev/mmcblk1p1\0" \ "bootcmd_rd_in_mmc=ext4load mmc 1:1 $kernel_addr_r /boot$kernel_image; " \ "bootm $kernel_addr_r\0" \ - "bootcmd=run shieldcmd; run bootcmd_otenv; run bootcmd_rd_in_mmc\0" \ + "boot_ostree=run shieldcmd; run bootcmd_otenv; run bootcmd_rd_in_mmc\0" \ \ /* NRSW boot */ \ "root_part=1\0" /* from NRSW, required here? set from board.c */ \ @@ -170,13 +163,15 @@ int eth_phy_timeout(void); "fdt addr $fdt_addr;if fdt get value mmc_dev /nm_env nm,mmc-dev;then;else setenv mmc_dev mmcblk0;fi;" \ "run add_sd_bootargs; run add_version_bootargs; run shieldcmd; " \ "bootz $kernel_addr - $fdt_addr; fi\0" \ - /* "bootcmd=run sdboot\0" */ \ \ - /* Recovery boot */ \ + /* Boot command */ \ + "bootcmd=" MAIN_BOOTCMD "\0" \ + \ + /* Recovery boot (same for OSTree and NRSW) */ \ "recovery=run pxe_recovery || setenv ipaddr $ipaddr; setenv serverip $serverip; run tftp_recovery\0" \ - /* setenv ipaddr and serverip is necessary, because dhclient can destroy the IPs internally */ \ + /* setenv ipaddr and serverip is necessary, because dhclient destroys the IPs internally */ \ "pxe_recovery=mdio up $ethprime && dhcp && pxe get && pxe boot\0" \ - "tftp_recovery=tftpboot $kernel_addr_r recovery-image; tftpboot $fdt_addr_r recovery-dtb; " /* kernel_addr_r ? */ \ + "tftp_recovery=tftpboot $kernel_addr_r recovery-image; tftpboot $fdt_addr_r recovery-dtb; " \ "setenv bootargs rdinit=/etc/preinit console=$defaultconsole,115200 " \ "debug $ethopts; " \ "bootz $kernel_addr_r - $fdt_addr_r\0" /* kernel_addr_r */ @@ -280,7 +275,7 @@ int eth_phy_timeout(void); #define CONFIG_SYS_MEMTEST_END 0x87900000 -#ifdef CONFIG_NRSW +#ifdef CONFIG_NRSW_BUILD /* support for NM packed bootloader */ #define CONFIG_NM_BOOTLOADER_FORMAT @@ -299,7 +294,7 @@ int eth_phy_timeout(void); #define CONFIG_JTAG_MARKER_UBOOT 0x807FFF00 /* NRSW PMIC Reset Reason */ -#ifdef CONFIG_NRSW +#ifdef CONFIG_NRSW_BUILD #define RESET_REASON_SHM_LOCATION 0x8e000000 #define EXTERNAL_WATCHDOG_PATTERN 0x781f9ce2 #endif