Issues creating a bootable SD


(Drew DeVault) #1

Hiya! I have a known working microSD card with my own bbl (Linux 4.20
w/patches) and root filesystem (Alpine Linux). This boots up and works fine,
and is my baseline for preparing a second SD card.

I use the following(ish) script to prepare the new card:

BBL=2E54B353-1271-4842-806F-E436D6AF6985
LINUX=0FC63DAF-8483-4772-8E79-3D69D8477DE4

echo "Partitioning disk..."
sgdisk --clear \
	--new=1:2048:67583 --change-name=1:bootloader --typecode=1:$BBL \
	--new=2:264192: --change-name=2:root --typecode=2:$LINUX \
	"$bdev"

echo "Writing BBL to disk..."
dd if="$bblpath" of="$bdev"1 bs=4096

echo "Preparing filesystem..."
mkfs.ext4 "$bdev"2
mount "$bdev"2 /mnt

echo "Extracting root..."
tar -C /mnt -xpvf "$roottar"

sync
umount /mnt

Afterwards, I took a dump of the bbl partition from my known working SD card
and compared the SHA to a dump from the new SD card’s bbl partition - and they
match. Examining both disks with gdisk also show that they are apparently
identical, except with respect to the size of the second partition (the new
disk is 128G, the known working disk is 8G).

The new SD card does not boot. The UART shows the serial number of my board and
stops there, not showing the logo baked into my BBL and not booting Linux.


(Jim Wilson) #2

It looks like you created the second SDcard OK. Not clear why it doesn’t work. If the fsbl failed to find the sdcard or bbl it would print an error message, something like 0x00000003 or 0x00000005. You will have to experiment to figure out what is wrong. You can try a different way of creating a second sdcard, or maybe try a different sdcard in case you have a bad one. In freedom-u-sdk, “make format-boot-loader” should produce a bootable sdcard. You also try using dd to copy the entire contents of the first sdcard into a file, and then use dd to copy the file onto the second sdcard.


(Drew DeVault) #3

Thanks. I figured I had it right but wanted to confirm with the experts before getting too creative. I think my next step is going to be copying the known-good card onto the questionable card, and then maybe trying another card entirely if I can dig one up.


(Drew DeVault) #4

Adding details from UART. If I power it up without an SD card at all:

Error 0x1000000000000005

With the bad SD card:

SiFive FSBL:       2018-03-20
HiFive-U serial #: 00000204
[no further messages]

And with the good SD card:

SiFive FSBL:       2018-03-20
HiFive-U serial #: 00000204
bbl loader
              vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
                  vvvvvvvvvvvvvvvvvvvvvvvvvvvv
rrrrrrrrrrrrr       vvvvvvvvvvvvvvvvvvvvvvvvvv
rrrrrrrrrrrrrrrr      vvvvvvvvvvvvvvvvvvvvvvvv
rrrrrrrrrrrrrrrrrr    vvvvvvvvvvvvvvvvvvvvvvvv
rrrrrrrrrrrrrrrrrr    vvvvvvvvvvvvvvvvvvvvvvvv
rrrrrrrrrrrrrrrrrr    vvvvvvvvvvvvvvvvvvvvvvvv
rrrrrrrrrrrrrrrr      vvvvvvvvvvvvvvvvvvvvvv
rrrrrrrrrrrrr       vvvvvvvvvvvvvvvvvvvvvv
rr                vvvvvvvvvvvvvvvvvvvvvv
rr            vvvvvvvvvvvvvvvvvvvvvvvv      rr
rrrr      vvvvvvvvvvvvvvvvvvvvvvvvvv      rrrr
rrrrrr      vvvvvvvvvvvvvvvvvvvvvv      rrrrrr
rrrrrrrr      vvvvvvvvvvvvvvvvvv      rrrrrrrr
rrrrrrrrrr      vvvvvvvvvvvvvv      rrrrrrrrrr
rrrrrrrrrrrr      vvvvvvvvvv      rrrrrrrrrrrr
rrrrrrrrrrrrrr      vvvvvv      rrrrrrrrrrrrrr
rrrrrrrrrrrrrrrr      vv      rrrrrrrrrrrrrrrr
rrrrrrrrrrrrrrrrrr          rrrrrrrrrrrrrrrrrr
rrrrrrrrrrrrrrrrrrrr      rrrrrrrrrrrrrrrrrrrr
rrrrrrrrrrrrrrrrrrrrrr  rrrrrrrrrrrrrrrrrrrrrr

       INSTRUCTION SETS WANT TO BE FREE
OF: fdt: Ignoring memory range 0x80000000 - 0x80200000
Linux version 4.20.0-rc4+ (sircmpwn@homura) (gcc version 8.2.0 (GCC)) #20 SMP Sat Dec 15 14:28:52 E
ST 2018
[proceeds with normal Linux boot-up]

Boots normally if I copy a dump of the good SD card onto the new SD card… great.

Also, in this PDF: https://sifive.cdn.prismic.io/sifive%2F834354f0-08e6-423c-bf1f-0cb58ef14061_fu540-c000-v1.0.pdf section 6.3 has the incorrect GPT UUID (there’s an extra 1 on the end).


(Drew DeVault) #5

Works if I write the BBL last. ¯\_(ツ)_/¯


(Jim Wilson) #6

Odd that writing bbl last works, unless perhaps bbl is larger than the partition, and dd isn’t stopping at the end of the partition. The bbl write would then be overwriting part of your root file system. I think the fsbl has a limit on how much it can read from the sdcard, so making the partition larger may not work without changes to the fsbl.


(Drew DeVault) #7

I wondered that too, but it doesn’t make sense. My bbl is 4M and my BBL partition is 32M.


(Jim Wilson) #8

I have no further ideas to suggest.