ImageBuilder; Cannot upgrade OS running on eMMC

Does that have a permanent flash at all, or is it just memory card based?

With memory cards, things are naturally different, as the device itself has no permanent storage, so there is no original MAC stored anywhere.

Some devices can be bought without "unique" MAC, it's probably cheaper, since they only have to pay the NIC vendor once, instead of every time they sell a new device.

2 Likes

Apparently the Mac is generated by OpenWrt by hashing a a device ID or something like that.

The behavior of constantly changing MAC devices is extremely frustrating.
I use the MAC to identify all devices on my networks but this one keeps changing, repeatedly even once the router is up and running.

I decided to hard code MAC addresses into the network file but now I found a new problem. I re-built my firmware using ImageBuilder which I transfer to /tmp. Openwrt is running on the eMMC now, not an sd card.

However, as mentioned in another post, I just found another weird thing about this router or something I'm not aware of.

When running sysupgrade -n myfile.bin.gz, the console implies that it's doing the upgrade but when I log back into the router, it's the same as it was. In fact, even on reboots, the things I left in /tmp are still there.

I'm wondering if perhaps it's not possible to upgrade the firmware using sysupgrade when the OS is on eMMC.

# sysupgrade -n ID58-nanopi-r5c-2024-02-13.bin.gz
Tue Feb 13 22:55:45 UTC 2024 upgrade: Reading partition table from bootdisk...
Tue Feb 13 22:55:45 UTC 2024 upgrade: Reading partition table from image...
Tue Feb 13 22:55:45 UTC 2024 upgrade: Commencing upgrade. Closing all shell sessions.
Command failed: Connection failed

What's interesting is the router has a 32GB eMMC but it looks like only 8G of it was used when I originally flashed it. Maybe that's why sysupgrade is failing, not enough space?

Disk /dev/mmcblk1: 28.91 GiB, 31037849600 bytes, 60620800 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x5452574f

Device         Boot  Start    End Sectors  Size Id Type
/dev/mmcblk1p1 *     65536  98303   32768   16M 83 Linux
/dev/mmcblk1p2      131072 344063  212992  104M 83 Linux

# df -h
Filesystem                Size      Used Available Use% Mounted on
/dev/root                 7.5M      7.5M         0 100% /rom
tmpfs                   995.6M     13.9M    981.6M   1% /tmp
/dev/loop0               84.4M      1.0M     76.7M   1% /overlay
overlayfs:/overlay       84.4M      1.0M     76.7M   1% /
tmpfs                   512.0K         0    512.0K   0% /dev

In terms of the MAC, It seems these routers are sold as regular and enterprise. Regular have dynamic MAC while enterprise ones have static MAC.

Because of this, I suspect there will be no original MAC to be found on the hardware.

Is there a way to specify the size of the storage when building an image?
I'm guessing not.

I flashed a FriendlyWrt eflesher onto an sd card then used that to auto flash the eMMC with friendlyWrt.

What's interesting is the default partitioning that I now see.

root@FriendlyWrt:~# fdisk -l /dev/mmcblk2
Disk /dev/mmcblk2: 28.91 GiB, 31037849600 bytes, 60620800 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 73987B6B-4974-4C94-A3E8-58AB2EB7A946

Device           Start      End  Sectors  Size Type
/dev/mmcblk2p1   16384    24575     8192    4M unknown
/dev/mmcblk2p2   24576    32767     8192    4M unknown
/dev/mmcblk2p3   32768    40959     8192    4M unknown
/dev/mmcblk2p4   40960    73727    32768   16M unknown
/dev/mmcblk2p5   73728   155647    81920   40M unknown
/dev/mmcblk2p6  155648   221183    65536   32M unknown
/dev/mmcblk2p7  221184   286719    65536   32M unknown
/dev/mmcblk2p8  286720  1466367  1179648  576M unknown
/dev/mmcblk2p9 1466368 60620766 59154399 28.2G unknown

root@FriendlyWrt:~# df -h
Filesystem      Size  Used Avail Use% Mounted on
tmpfs           512K     0  512K   0% /dev
tmpfs           196M  152K  196M   1% /run
overlay          28G  744K   27G   1% /
tmpfs           982M   21M  961M   3% /tmp

If I were to use sysupgrade to flash my own image, assuming it would work, would it end up being installed on partition9?
And if it were, would that mean I would end up with partition9 becoming a couple of partitions and openwrt would not see any more storage than 8GB again? I don't know how it picked 8GB but the only thing I can think of is that perhaps the original sd card I used was an 8GB one?

I really don't know, I'm just guessing at this point and no idea how to move forward.

There is, if you use your own image builder, not the online one.

As for the MAC issue, is there a boot loader, like u-boot, where you could set a MAC address variable, then pick it up in OpenWRT ?
This would survive upgrades.

Yes, I can set the MAC addresses but what I was after was finding the factory ones so they would be truly unique and not my own. Now I know these devices do not come with a fixed MAC so it's unlikely there is any info in the hardware.

My real problem at this point is not being able to use the full eMMC which is likely why I cannot upgrade the OS using sysupgrade.

I've yet to find information on how I can fix this. I was wondering if maybe I need to boot from sd card, wipe the partition from the eMMC, then run eflasher to flash back to eMMC then upgrade. Maybe at that point, I get more space or it's the eflasher that's partitioning the eMMC as it is and it means I need to put my own openwrt image for eflasher to flash.

Bit confusing all this.

The MAC issue is solved;

Is there a bug in the ImageBuilder?
I just found this out. I'm using files/ to store my own custom settings etc and I've noticed that when I build, a new file I put there gets removed if I run make clean and make dirclean before building a profile.

I don't recall any files in files/ being removed when running those commands first and I've used IB hundreds of times.

So this time, I built an image using IB and used dd to write it to a 32GB sd card.
I then booted the SD card on this device and checked the partitions, space etc.
What confuses me is why the full device is never being used?
This still seems to be maxed out at 8GB or so.

# fdisk -l
Disk /dev/loop0: 96.44 MiB, 101122048 bytes, 197504 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/mmcblk0: 29.54 GiB, 31719424000 bytes, 61952000 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x5452574f

Device         Boot  Start    End Sectors  Size Id Type
/dev/mmcblk0p1 *     65536  98303   32768   16M 83 Linux
/dev/mmcblk0p2      131072 344063  212992  104M 83 Linux


Disk /dev/mmcblk1: 28.91 GiB, 31037849600 bytes, 60620800 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x5452574f

Device         Boot  Start    End Sectors  Size Id Type
/dev/mmcblk1p1 *     65536  98303   32768   16M 83 Linux
/dev/mmcblk1p2      131072 344063  212992  104M 83 Linux


Disk /dev/mmcblk1boot0: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/mmcblk1boot1: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

# df -h
Filesystem                Size      Used Available Use% Mounted on
/dev/root                 7.8M      7.8M         0 100% /rom
tmpfs                   995.6M      1.2M    994.4M   0% /tmp
/dev/loop0               84.4M    699.0K     77.0M   1% /overlay
overlayfs:/overlay       84.4M    699.0K     77.0M   1% /
tmpfs                   512.0K         0    512.0K   0% /dev

I'm at a loss here, been at this for over a week and unable to solve the problem. No matter if I use the sd card or the on board eMMC, I cannot use the full size of the storage and this means I cannot run sysupgrade to write a new fw to the device.

What could be causing this?

Did you tell image builder to increase the FS' size ?

This is something I've been looking into but cannot find concrete info on how to do it.

When I write the openwrt image to the sdcard, this is the command I'm using
sudo dd if=r5c-2024-02-15.bin of=/dev/sdb bs=4M status=progress

From what I've read, the dd command writes the OpenWrt image directly to the SD card, but it only writes as much data as is contained in the r5c-2024-02-15.bin image file. This means only a portion of the SD card is used, specifically the size of the OpenWrt image.

But, I've yet to find enough information to know how to fix this. I'm using the sd card first but eventually want to run the OS directly off of the built in eMMC but I need the full space so I can remotely use sysupgrade as needed.

As I understand it...

When I write the OpenWrt image to the SD card using the dd command, I am effectively copying a pre-configured filesystem structure and operating system onto the card. This image has a fixed size, which is usually much smaller than the capacity of the SD card, especially if using a large one like 32GB.

There are bits of information on using tools to change the partition sizes etc but I can't use those unless it's a one time thing because from remote, I would not dare messing with partitions.

Again, from the little I understand, I should be changing some partition stuff on the sd card after it's written but before putting it into the router. Confusing when you've not done something like this before.

I've never had a problem until I used this nanopi r5c. I've used other nanopi and never had the issue so I don't know what's different about this one or what steps I must have taken at some point to cause this.

I found this which worked but only up until I re-flashed the image in-place.
Meaning, first I dd'd the .img from the sd card to the eMMC.
Then I ran the automated example found here;
https://openwrt.org/docs/guide-user/advanced/expand_root

After rebooting from the eMMC now, the full space of the eMMC was being used.
So to test, I then copied a new image to /tmp and used sysupgrade which completed but after reboot, the same size returned.

This doesn't seem to keep permanently. It seems this has to be run after any sysupgrade was done.

What has worked so far is the link I shared.
I created the two files, I then created the sysupgrade.conf as shown and now everything seems to work with all of the storage space being used.

What an interesting and challenging problem this was.

Thank you for all of the help. I hope this thread helps someone else.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.