LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer
User Name
Password
Linux - Embedded & Single-board computer This forum is for the discussion of Linux on both embedded devices and single-board computers (such as the Raspberry Pi, BeagleBoard and PandaBoard). Discussions involving Arduino, plug computers and other micro-controller like devices are also welcome.

Notices


Reply
  Search this Thread
Old 08-06-2023, 02:29 PM   #1
Ricky12
LQ Newbie
 
Registered: Aug 2017
Posts: 4

Rep: Reputation: Disabled
Image is not of type ARM barebox image but of type MBR sector, update failed


I have phyBOARD-MIRA i.MX6 development board from PHYTEC. It comes with preinstalled barebox bootloader on NAND Flash, and one can build embedded Linux distribution (more or less) easily using Yocto and documentation of PHYTEC.

I have built new embedded Linux distribution using Yocto (with new barebox), I have copied it to SD Card as shown later below, set switch S2 on phyBOARD-MIRA i.MX6 to ON so that Linux boots from SD Card, and I was happy with how it works. Barebox bootloader is still old Barebox from NAND Flash.

Now I am trying to flash everything from this SD Card to NAND Flash on embedded board. When I stop autoboot of embedded board and try flashing barebox like this:

Code:
barebox_update -t nand /dev/mmc0.barebox
I get following error:

Quote:
UPDATE: Image is not of type ARM barebox image but of type MBR sector

update failed
This is what is written in documentation of PHYTEC:

Quote:
In case that your phyBOARD-Mira i.MX 6 does not start anymore due to a damaged bootloader, you need to boot from an SD card. This SD card must be formatted in a special way, because the i.MX 6 does not use file systems. Instead it is hard coded at which sectors of the SD card the i.MX 6 expects the bootloader.

Bitbake, a tool integrated in Yocto, builds an image with the ending *.sdcard which fulfills the requirements mentioned above. So we can copy this image to an SD card with the help of dd.

Now use the following command to create your bootable SD card:

Code:
sudo dd if=phytec‐qt5demo‐image‐phyboard‐mira‐imx6‐*.sdcard
of=/dev/<DEVICE>
I am using dd to create bootable sd card, I am only using Cygwin dd instead on normal dd from Linux. They are probably same, but SD card seems to still have old NTFS or exFAT filesystem which is bad for my barebox. I have three components of embedded Linux distribution which stem from this *.sdcard file: barebox, linuximage and oftree, but MBR sector at the beginning of SD card seems to make SD card less usable.

Did anyone have similar problems, and is there anything more useful than this dd command?
 
Old 08-07-2023, 06:50 AM   #2
Emerson
LQ Sage
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~amd64
Posts: 7,661

Rep: Reputation: Disabled
Code:
of=/dev/<DEVICE>
This looks suspicious to me. What device? You may be putting this image to a partition, this would explain why boot sector is untouched.
 
Old 08-07-2023, 07:01 AM   #3
Ricky12
LQ Newbie
 
Registered: Aug 2017
Posts: 4

Original Poster
Rep: Reputation: Disabled
Well, I am writing as of=/dev/sdb .
These are the partitions, whereby my SD Card is D:

Code:
wwwri@LAPTOP-HO38O9KH /cygdrive/c
$ cat /proc/partitions
major minor  #blocks  name   win-mounts

    8     0 500107608 sda
    8     1    266240 sda1
    8     2     16384 sda2
    8     3 498799616 sda3   C:\
    8     4   1024000 sda4
    8    16  62334976 sdb
    8    17     26624 sdb1   D:\
    8    18    371800 sdb2
 
Old 08-07-2023, 07:29 AM   #4
Emerson
LQ Sage
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~amd64
Posts: 7,661

Rep: Reputation: Disabled
I do not know anything about this Windows business, will be 19 years this fall without MS for me.
Anyhow, your SD card is not D, the first partition of sdb is marked as D. Considering the error you are getting I bet you are writing to sdb1.
 
Old 08-07-2023, 07:47 AM   #5
Ricky12
LQ Newbie
 
Registered: Aug 2017
Posts: 4

Original Poster
Rep: Reputation: Disabled
When I use
Code:
dd if=phytec-qt5demo-image-phyboard-mira-imx6-3.sdcard  of=/dev/sdb bs=1M conv=fsync
embedded board still boots, but barebox can not be updated.
With
Code:
of=/dev/sdb1
instead of
Code:
of=/dev/sdb
embedded board does not boot.
 
Old 08-07-2023, 08:11 AM   #6
Emerson
LQ Sage
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~amd64
Posts: 7,661

Rep: Reputation: Disabled
Quote:
... barebox can not be updated.
Seems like a separate issue.
 
Old 08-10-2023, 10:05 AM   #7
a3f
LQ Newbie
 
Registered: Aug 2023
Posts: 1

Rep: Reputation: 1
Quote:
Now I am trying to flash everything from this SD Card to NAND Flash on embedded board.
It's usual for SD-Cards to have an on-disk partition table, e.g. MBR in your case, but this is not the norm for NAND.
Even if you flash your SD-Card completely to NAND, it will not behave as you expect. The Phytec BSP can probably
generate images for NAND as well, which you should rather use.

A usual setup is having the NAND partitioning described in the device tree, then you use barebox_update to install
barebox into the NAND and then the kernel, device tree and rootfs are in an UBI/UBIFS.

I think the Phytec documentation should help you with all that. In general, it's often easiest to flash over USB:
Code:
barebox$ usbgadget -A /dev/nand0.root(root-nand)u -b
host$ fastboot getvar all # list all flashable partitions
host$ fastboot flash root-nand my-image.ubi
host$ fastboot flash bbu-nand barebox-phytec-something.img
Replace /dev/nand0.root with whatever the name of your root partition is.

Quote:
When I stop autoboot of embedded board and try flashing barebox like this:
Code:
barebox_update -t nand /dev/mmc0.barebox
Code:
 UPDATE: Image is not of type ARM barebox image but of type MBR sector

update failed
That's expected: If you run devinfo, you'll see that the barebox partition starts at
address 0. That's ok, because the i.MX6 BootROM only cares about what's at location 0x400
of the SD-Card. barebox_update though will try to guess what kind of image it's given
to protect your from soft-bricking your device.
As you are pointing it at the start of the SD-Card, it will see the MBR 0xaa55 magic and
tell you that it's not what it expects.

In your case, because you know that the image is valid despite the mismatched header,
you can pass barebox_update the force flag -f, so it ignores the header check.

Another way is to update barebox over USB or over the network and use a pristine barebox image
that hasn't been mangled by writing MBR magic over it.
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
buildroot stage 1 fails at barebox w 'cant find default configuration' lazardo Slackware - ARM 4 04-29-2022 11:10 AM
[SOLVED] Is MBR in the boot block/sector or is MBR the boot block/sector? ultra_reader Linux - Newbie 10 02-14-2019 03:45 PM
[SOLVED] smart detects sector errors, but does not show which sector? LBM Linux - Hardware 11 06-04-2018 04:52 AM
[SOLVED] Barebox on Phytec usb drive detection GeneCode Linux - Embedded & Single-board computer 6 08-28-2017 10:08 PM
Which program can boot a copy of the MBR (fake MBR) using mbr.bin Xeratul Linux - Software 6 12-03-2010 11:40 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer

All times are GMT -5. The time now is 08:27 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration