ofi:vscode-ev3

Native Python auf EV3 mit VSCode

Way better than stuff below (also, you could take the image and then zero is out while mounted as loopback, much quicker!)

def cmd(c)
  puts c
  r = `#{c}`
  return r
end
 
raise "Provide hostname (like LEGO01)" unless $ARGV[0]
hostname = $ARGV[0]
 
img = "lego01.img"
cmd("losetup -Pf #{img}")
dev = cmd("losetup -j #{img}").split(":")[0]
 
p2 = dev+"p2"
cmd("mkdir -p p2")
cmd("mount #{p2} p2")
puts "Writing hostname #{hostname} to image"
cmd("echo #{hostname} > p2/etc/hostname")
cmd("umount p2")
 
cmd("losetup -d ${dev}")
puts "Image is ready. Write it with"
puts "dd if=#{img} of=/dev/sdXXXX status=progress bs=1M conv=sparse"
# Get Info
sudo fdisk -lu lego12.img 
Disk lego12.img: 14.84 GiB, 15931539456 bytes, 31116288 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: 0xf5e5f871
 
Device      Boot  Start      End  Sectors  Size Id Type
lego12.img1        8192   106495    98304   48M  b W95 FAT32
lego12.img2      106496 31116287 31009792 14.8G 83 Linux
 
 
 
# Mount Partition, -o Start*512, --sizelimit Sectors*512
sudo losetup -o 54525952 -b 512 --sizelimit 15877013504 /dev/loop16 lego12.img
 
# Check filesystem
sudo e2fsck -f /dev/loop16
 
# Resize filesystem
sudo resize2fs /dev/loop16 3750000
 
# Mount filesystem
mount /dev/loop16 /mnt
 
# Zero out disk
dd if=/dev/zero of=zero.txt bs=1M status=progress
 
# Truncate image (size obtained from target SD-Card with fdisk -lu /dev/sda)
truncate -s 15634268160 lego12.img
  • ofi/vscode-ev3.txt
  • Last modified: 2022/07/17 08:34
  • by Ivo Blöchliger