Re: Booting from NAND on an Armada-370 based machine -> Invalid header checksum
Hello, first of all thanks for your reply and also your ideas on irc. The machine started to properly boot now after I changed the UART-to-USB adapter. (The first one I used stopped providing the /dev/ttyUSB0 device on my host machine and got quite hot.) Maybe this is related to the UART TX pin being a bootstrap pin that selects the boot medium and the used mode!? My answers below just for the record ... On 9/5/21 6:20 PM, Pali Rohár wrote: On Sunday 05 September 2021 17:48:16 Uwe Kleine-König wrote: I'm trying to unbrick a Netgear ReadyNAS 104 (Armada 370). (I accidentally erased the u-boot partition in NAND when I tried to change the NAND partitioning to make the Debian bullseye kernel+initramfs fit.) I have the Vendor U-Boot image that I can boot using kwboot. Its first byte is 0x8b which is the right for NAND booting. The image's size is 0xda548 bytes. I wrote the image to the start of NAND and verified it to be correctly written: Marvell>> nand read 0x210 0 0xda548 NAND read: device 0 offset 0x0, size 0xda548 894280 bytes read: OK Marvell>> dhcp egiga1 wait for link .Done - link up. ... DHCP client bound to address 192.168.77.145 Marvell>> tftp 0x200 192.168.77.175:u-boot-rn104-2.0.img Using egiga1 device TFTP from server 192.168.77.175; our IP address is 192.168.77.145 Filename 'u-boot-rn104-2.0.img'. Load address: 0x200 Loading: # done Bytes transferred = 894280 (da548 hex) Marvell>> cmp.b 0x200 0x210 0xda548 Total of 894280 bytes were the same There are no bad blocks in this area. Also the checksum is right as far as I understand: $ python3 ... >>> a = open("/srv/tftp/u-boot-rn104-2.0.img", "rb") >>> data = a.read(0x14000) >>> len(data) 81920 >>> hex(sum(data[:31]) + sum(data[32:])) '0x79f616' So the checksum field should be 0x16 (at offset 31), which it is: Marvell>> md.b 0x210 0210: 8b 00 00 00 48 65 0c 00 01 01 00 40 00 40 01 00 He.@.@.. So... Image version = 0x01 Header Size MSB = 0x01 Header Size LSB = 0x00 0x40 = 0x4000 So header size is 0x014000 = 81920 02100010: 00 00 00 00 00 00 00 00 00 02 01 00 00 00 01 16 Checksum = 0x16 Which seems that the header checksum is correct. 02100020: 02 01 18 35 02 00 00 00 5b 00 00 00 00 00 00 00 ...5[... 02100030: ff 5f 2d e9 1c 00 00 fa 00 00 a0 e3 ff 9f bd e8 ._-. Still when trying to boot I get: BootROM 1.08 Booting from NAND flash BootROM: Invalid header checksum BootROM: Bad header at offset 0001 BootROM: Bad header at offset 0002 BootROM: Bad header at offset 0003 BootROM: Bad header at offset 0004 BootROM: Bad header at offset 0005 BootROM: Bad header at offset 0006 BootROM: Bad header at offset 0007 BootROM: Bad header at offset 0008 BootROM: Bad header at offset 0009 BootROM: Bad header at offset 000A BootROM: Bad header at offset 000B BootROM: Bad header at offset 000C BootROM: Bad header at offset 000D BootROM: Bad header at offset 000E BootROM: Bad header at offset 000F BootROM: Bad header at offset 0010 BootROM: Bad header at offset 0011 BootROM: Bad header at offset 0012 BootROM: Bad header at offset 0013 BootROM: Bad header at offset 0014 BootROM: Bad header at offset 0015 BootROM: Bad header at offset 0016 BootROM: Bad header at offset 0017 BootROM: Bad header at offset 0018 BootROM: Bad header at offset 0019 BootROM: Bad header at offset 001A BootROM: Bad header at offset 001B BootROM: Bad header at offset 001C BootROM: Bad header at offset 001D BootROM: Bad header at offset 001E BootROM: Bad header at offset 001F BootROM: Bad header at offset 0020 BootROM: Bad header at offset 0021 BootROM: Bad header at offset 0022 ... Is there anything obvious I'm missing or doing wrong? Does "Invalid header checksum" indicate that the 0x16 is wrong or is there another checksum anywhere that I missed? Any other idea? Image version 1 has only one header checksum (at 0x1F) and one data checksum (4 bytes at the end of data image). But data checksum can be verified only after loading data image to the RAM, which can happen only after executing binary headers. If you are using standard DDR train
Booting from NAND on an Armada-370 based machine -> Invalid header checksum
Hello, I'm trying to unbrick a Netgear ReadyNAS 104 (Armada 370). (I accidentally erased the u-boot partition in NAND when I tried to change the NAND partitioning to make the Debian bullseye kernel+initramfs fit.) I have the Vendor U-Boot image that I can boot using kwboot. Its first byte is 0x8b which is the right for NAND booting. The image's size is 0xda548 bytes. I wrote the image to the start of NAND and verified it to be correctly written: Marvell>> nand read 0x210 0 0xda548 NAND read: device 0 offset 0x0, size 0xda548 894280 bytes read: OK Marvell>> dhcp egiga1 wait for link .Done - link up. ... DHCP client bound to address 192.168.77.145 Marvell>> tftp 0x200 192.168.77.175:u-boot-rn104-2.0.img Using egiga1 device TFTP from server 192.168.77.175; our IP address is 192.168.77.145 Filename 'u-boot-rn104-2.0.img'. Load address: 0x200 Loading: # done Bytes transferred = 894280 (da548 hex) Marvell>> cmp.b 0x200 0x210 0xda548 Total of 894280 bytes were the same There are no bad blocks in this area. Also the checksum is right as far as I understand: $ python3 ... >>> a = open("/srv/tftp/u-boot-rn104-2.0.img", "rb") >>> data = a.read(0x14000) >>> len(data) 81920 >>> hex(sum(data[:31]) + sum(data[32:])) '0x79f616' So the checksum field should be 0x16 (at offset 31), which it is: Marvell>> md.b 0x210 0210: 8b 00 00 00 48 65 0c 00 01 01 00 40 00 40 01 00 He.@.@.. 02100010: 00 00 00 00 00 00 00 00 00 02 01 00 00 00 01 16 02100020: 02 01 18 35 02 00 00 00 5b 00 00 00 00 00 00 00 ...5[... 02100030: ff 5f 2d e9 1c 00 00 fa 00 00 a0 e3 ff 9f bd e8 ._-. Still when trying to boot I get: BootROM 1.08 Booting from NAND flash BootROM: Invalid header checksum BootROM: Bad header at offset 0001 BootROM: Bad header at offset 0002 BootROM: Bad header at offset 0003 BootROM: Bad header at offset 0004 BootROM: Bad header at offset 0005 BootROM: Bad header at offset 0006 BootROM: Bad header at offset 0007 BootROM: Bad header at offset 0008 BootROM: Bad header at offset 0009 BootROM: Bad header at offset 000A BootROM: Bad header at offset 000B BootROM: Bad header at offset 000C BootROM: Bad header at offset 000D BootROM: Bad header at offset 000E BootROM: Bad header at offset 000F BootROM: Bad header at offset 0010 BootROM: Bad header at offset 0011 BootROM: Bad header at offset 0012 BootROM: Bad header at offset 0013 BootROM: Bad header at offset 0014 BootROM: Bad header at offset 0015 BootROM: Bad header at offset 0016 BootROM: Bad header at offset 0017 BootROM: Bad header at offset 0018 BootROM: Bad header at offset 0019 BootROM: Bad header at offset 001A BootROM: Bad header at offset 001B BootROM: Bad header at offset 001C BootROM: Bad header at offset 001D BootROM: Bad header at offset 001E BootROM: Bad header at offset 001F BootROM: Bad header at offset 0020 BootROM: Bad header at offset 0021 BootROM: Bad header at offset 0022 ... Is there anything obvious I'm missing or doing wrong? Does "Invalid header checksum" indicate that the 0x16 is wrong or is there another checksum anywhere that I missed? Any other idea? If you have an idea and prefer irc over email, I hang around e.g. in #mvlinux on libera as ukleinek. Best regards Uwe signature.asc Description: PGP signature
Re: [PATCH] rk3399: Add basic support for helios64
Hi Peter, On 2/26/21 3:56 PM, Peter Robinson wrote: On Fri, Feb 26, 2021 at 1:45 PM Uwe Kleine-König wrote: On 2/26/21 12:23 AM, Dennis Gilmore wrote: Thanks for submitting, I have been meaning to do so myself, I have been meaning to go through and try get the dts files in a decent shape. I think that most of what is in arch/arm/dts/rk3399-kobol-helios64-u-boot.dtsi belongs in arch/arm/dts/rk3399-kobol-helios64.dts I understood that the intention of the separation into two files is that the one should track the Linux dts. Is that wrong? No, that's correct, but it should also likely then be submitted for upstream Linux inclusion. Yeah, that's the eventual plan. For now I want to get a booting system into Debian and so several interfaces are not included. After that I intend to improve the support in both Linux and U-Boot. Best regards Uwe OpenPGP_signature Description: OpenPGP digital signature
Re: [PATCH] rk3399: Add basic support for helios64
Hi Dennis, thanks for your feedback. On 2/26/21 12:23 AM, Dennis Gilmore wrote: Thanks for submitting, I have been meaning to do so myself, I have been meaning to go through and try get the dts files in a decent shape. I think that most of what is in arch/arm/dts/rk3399-kobol-helios64-u-boot.dtsi belongs in arch/arm/dts/rk3399-kobol-helios64.dts I understood that the intention of the separation into two files is that the one should track the Linux dts. Is that wrong? I also wonder if we shouldn't default to building an image for use in the SPI flash since the system has it available. I didn't test that but expected that I can write the resulting image to the spi flash and it works just fine. If you want something else here I need some direction about what to change. Best regards Uwe OpenPGP_signature Description: OpenPGP digital signature
[PATCH] rk3399: Add basic support for helios64
This is a stripped down version of the vendor U-Boot patch by Aditya Prayoga found in the armbian repository. This patch is enough to have the 1G ethernet port, the micro SD card, eMMC and UART operational and let it boot a Debian netboot installer. The device tree is contained in Linux v5.11-rc1. During my work on U-Boot I noticed a wrong pull setting, the corresponding patch is still in linux-next and already applied in the copy that is added by this patch. Signed-off-by: Uwe Kleine-König --- Hello, @Aditya: I kept you as maintainer in MAINTAINERS, is this ok for you? I doubt that I'm qualified enough for that. So please wait for this question to be resolved before you apply this patch. Best regards Uwe arch/arm/dts/Makefile | 1 + .../arm/dts/rk3399-kobol-helios64-u-boot.dtsi | 266 + arch/arm/dts/rk3399-kobol-helios64.dts| 372 ++ arch/arm/mach-rockchip/rk3399/Kconfig | 17 + board/kobol/helios64/Kconfig | 24 ++ board/kobol/helios64/MAINTAINERS | 6 + board/kobol/helios64/Makefile | 5 + board/kobol/helios64/helios64.c | 262 board/kobol/helios64/sys_otp.c| 248 board/kobol/helios64/sys_otp.h| 10 + configs/helios64-rk3399_defconfig | 142 +++ include/configs/helios64.h| 47 +++ 12 files changed, 1400 insertions(+) create mode 100644 arch/arm/dts/rk3399-kobol-helios64-u-boot.dtsi create mode 100644 arch/arm/dts/rk3399-kobol-helios64.dts create mode 100644 board/kobol/helios64/Kconfig create mode 100644 board/kobol/helios64/MAINTAINERS create mode 100644 board/kobol/helios64/Makefile create mode 100644 board/kobol/helios64/helios64.c create mode 100644 board/kobol/helios64/sys_otp.c create mode 100644 board/kobol/helios64/sys_otp.h create mode 100644 configs/helios64-rk3399_defconfig create mode 100644 include/configs/helios64.h diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile index fd47e408f826..752ba4fd8b35 100644 --- a/arch/arm/dts/Makefile +++ b/arch/arm/dts/Makefile @@ -125,6 +125,7 @@ dtb-$(CONFIG_ROCKCHIP_RK3399) += \ rk3399-ficus.dtb \ rk3399-firefly.dtb \ rk3399-gru-bob.dtb \ + rk3399-kobol-helios64.dtb \ rk3399-khadas-edge.dtb \ rk3399-khadas-edge-captain.dtb \ rk3399-khadas-edge-v.dtb \ diff --git a/arch/arm/dts/rk3399-kobol-helios64-u-boot.dtsi b/arch/arm/dts/rk3399-kobol-helios64-u-boot.dtsi new file mode 100644 index ..84a27548a08d --- /dev/null +++ b/arch/arm/dts/rk3399-kobol-helios64-u-boot.dtsi @@ -0,0 +1,266 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (c) 2020 Aditya Prayoga (adi...@kobol.io) + */ + +#include "rk3399-u-boot.dtsi" +#include "rk3399-sdram-lpddr4-100.dtsi" + +/ { + aliases { + spi0 = + ethernet0 = + }; + + chosen { + bootargs = "earlycon=uart8250,mmio32,0xff1a earlyprintk"; + stdout-path = "serial2:150n8"; + u-boot,spl-boot-order = "same-as-spl", , , + }; + + config { + u-boot,spl-payload-offset = <0x8>; /* @ 512KB */ + }; + + leds { + led-1 { + linux,default-trigger = "panic"; + }; + }; + + vcc3v0_sd: vcc3v0-sd { + startup-delay-us = <2>; + }; +}; + +_alert0 { + temperature = <8>; +}; + +_alert1 { + temperature = <95000>; +}; + +_crit { + temperature = <10>; +}; + + { + rk808: pmic@1b { + rockchip,system-power-controller; + + regulators { + vdd_center: DCDC_REG1 { + regulator-name = "vdd_center"; + regulator-always-on; + regulator-boot-on; + regulator-min-microvolt = <95>; + regulator-max-microvolt = <95>; + regulator-init-microvolt = <95>; + regulator-ramp-delay = <6001>; + regulator-state-mem { + regulator-on-in-suspend; + regulator-suspend-microvolt = <95>; + }; + }; + + vcc_ddr_s3: DCDC_REG3 { + regulator-name = "vcc_ddr_s3"; + regulator-always-on; + regulator-boot-on; + regulator-state-mem { + regulator-on-in-suspend; +
[U-Boot] [PATCH] jffs2: remove unused code files
I failed to find where these two files are used and a few test compile runs with JFFS2 enabled succeeded also without these. --- The build-all script failed for me with $HOME/.buildman-toolchains/gcc-7.3.0-nolibc/arm-linux-gnueabi/bin/../libexec/gcc/arm-linux-gnueabi/7.3.0/cc1: error while loading shared libraries: libisl.so.15: cannot open shared object file: No such file or directory I didn't try to make that work and instead compiled a few configs I generated by hand. Best regards Uwe fs/jffs2/jffs2_nand_1pass.c | 1036 - fs/jffs2/jffs2_nand_private.h | 133 - 2 files changed, 1169 deletions(-) delete mode 100644 fs/jffs2/jffs2_nand_1pass.c delete mode 100644 fs/jffs2/jffs2_nand_private.h diff --git a/fs/jffs2/jffs2_nand_1pass.c b/fs/jffs2/jffs2_nand_1pass.c deleted file mode 100644 index b16005e6045f.. --- a/fs/jffs2/jffs2_nand_1pass.c +++ /dev/null @@ -1,1036 +0,0 @@ -#include - -#include -#include -#include - -#include -#include -#include - -#include "jffs2_nand_private.h" - -#defineNODE_CHUNK 1024/* size of memory allocation chunk in b_nodes */ - -/* Debugging switches */ -#undef DEBUG_DIRENTS /* print directory entry list after scan */ -#undef DEBUG_FRAGMENTS /* print fragment list after scan */ -#undef DEBUG /* enable debugging messages */ - -#ifdef DEBUG -# define DEBUGF(fmt,args...) printf(fmt ,##args) -#else -# define DEBUGF(fmt,args...) -#endif - -static struct mtd_info *mtd; - -/* Compression names */ -static char *compr_names[] = { - "NONE", - "ZERO", - "RTIME", - "RUBINMIPS", - "COPY", - "DYNRUBIN", - "ZLIB", -#if defined(CONFIG_JFFS2_LZO) - "LZO", -#endif -}; - -/* Spinning wheel */ -static char spinner[] = { '|', '/', '-', '\\' }; - -/* Memory management */ -struct mem_block { - unsigned index; - struct mem_block *next; - char nodes[0]; -}; - -static void -free_nodes(struct b_list *list) -{ - while (list->listMemBase != NULL) { - struct mem_block *next = list->listMemBase->next; - free(list->listMemBase); - list->listMemBase = next; - } -} - -static struct b_node * -add_node(struct b_list *list, int size) -{ - u32 index = 0; - struct mem_block *memBase; - struct b_node *b; - - memBase = list->listMemBase; - if (memBase != NULL) - index = memBase->index; - - if (memBase == NULL || index >= NODE_CHUNK) { - /* we need more space before we continue */ - memBase = mmalloc(sizeof(struct mem_block) + NODE_CHUNK * size); - if (memBase == NULL) { - putstr("add_node: malloc failed\n"); - return NULL; - } - memBase->next = list->listMemBase; - index = 0; - } - /* now we have room to add it. */ - b = (struct b_node *)>nodes[size * index]; - index ++; - - memBase->index = index; - list->listMemBase = memBase; - list->listCount++; - return b; -} - -static struct b_node * -insert_node(struct b_list *list, struct b_node *new) -{ -#ifdef CONFIG_SYS_JFFS2_SORT_FRAGMENTS - struct b_node *b, *prev; - - if (list->listTail != NULL && list->listCompare(new, list->listTail)) - prev = list->listTail; - else if (list->listLast != NULL && list->listCompare(new, list->listLast)) - prev = list->listLast; - else - prev = NULL; - - for (b = (prev ? prev->next : list->listHead); -b != NULL && list->listCompare(new, b); -prev = b, b = b->next) { - list->listLoops++; - } - if (b != NULL) - list->listLast = prev; - - if (b != NULL) { - new->next = b; - if (prev != NULL) - prev->next = new; - else - list->listHead = new; - } else -#endif - { - new->next = (struct b_node *) NULL; - if (list->listTail != NULL) { - list->listTail->next = new; - list->listTail = new; - } else { - list->listTail = list->listHead = new; - } - } - - return new; -} - -static struct b_node * -insert_inode(struct b_list *list, struct jffs2_raw_inode *node, u32 offset) -{ - struct b_inode *new; - - if (!(new = (struct b_inode *)add_node(list, sizeof(struct b_inode { - putstr("add_node failed!\r\n"); - return NULL; - } - new->offset = offset; - new->version = node->version; - new->ino = node->ino; - new->isize = node->isize; - new->csize = node->csize; - - return insert_node(list, (struct b_node *)new); -} - -static struct