Comments (2)
Based on @dueringa's suggestion, this is the create-sd.sh
script that worked for me.
In case you are facing problems with that script.
#!/usr/bin/env bash
SDNAME="$1"
UIMGNAME="$2"
if [ "$#" -ne 2 ]; then
echo "Usage: "$0" sdimage uimage"
exit 1
fi
command -v qemu-img > /dev/null || { echo "qemu-img not installed"; exit 1; }
command -v qemu-nbd > /dev/null || { echo "qemu-nbd not installed"; exit 1; }
sudo modprobe nbd max_part=16 # <----- Added after @dueringa's suggestion
qemu-img create "$SDNAME" 64M
sudo qemu-nbd -c /dev/nbd0 "$SDNAME"
partprobe /dev/nbd0 # <----- Added after @dueringa's suggestion
(echo o;
echo n; echo p;
echo 1
echo ; echo
echo w; echo p) | sudo fdisk /dev/nbd0
sudo mkfs.ext2 /dev/nbd0p1
mkdir tmp || true
sudo mount -o user /dev/nbd0p1 tmp/
sudo cp "$UIMGNAME" tmp/
sudo umount /dev/nbd0p1
rmdir tmp/ || true
sudo qemu-nbd -d /dev/nbd0
from baremetal-arm.
nbd
seems not available on WSL, seems we should find a better way to handle this.
make_ext4fs
can create a ext based filesystem and genimage
can make a mbr image, and they doesn't need root permission. Next is a simple scripts can replace nbd
.
#!/usr/bin/env bash
SDNAME="$1"
UIMGNAME="$2"
if [ "$#" -ne 2 ]; then
echo "Usage: "$0" sdimage uimage"
exit 1
fi
command -v genimage >/dev/null || { echo "genimage not installed"; exit 1; }
rm -rf tmp rootfs
mkdir rootfs
cp "$UIMGNAME" rootfs
make_ext4fs -l 32M rootfs.ext4 rootfs
cat << EOF > genimage.cfg
image genimage_output.img {
hdimage {
}
partition rootfs {
partition-type = 0x83
image = "rootfs.ext4"
}
}
EOF
genimage --inputpath . --outputpath . genimage.cfg
mv genimage_output.img "${SDNAME}"
qemu-img resize "${SDNAME}" 64M
rm rootfs.ext4
from baremetal-arm.
Related Issues (14)
- Errata and troubleshooting on ArchLinux HOT 1
- QEMU problem with ALSA on Windows Subsystem for Linux HOT 1
- Wrong bit offset for word length selection HOT 2
- Tutorial #7 fails uart init HOT 1
- Errata Memory Mappings HOT 1
- CMake Build Issue HOT 1
- FDT and ATAGS support not compiled in resetting ... HOT 3
- Chapter 4: arm-none-eabi-ld -T linkscript.ld -o cenv.elf startup.o cstart.o HOT 1
- 04_cenv: data abort bug HOT 2
- 08_scheduler doesn't work HOT 3
- Chapter 04: cenv : NOT printing message to UART which is being sent by C code
- U-Boot section: Wrong command? HOT 8
- Wrong name of the global symbol in LinkerScript part HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from baremetal-arm.