Linux in 32MB Flash - Page 1
Forum section: electronics / general

author: technix
author_rank: Super Contributor
timestamp: March 22, 2017, 11:02:36 am
content: This is about one variation of my single board Linux computer project based on V3s. The chip can boot off SPI Flash, but the best chip I can use out there is W25Q256FV, a 32MB part.Now I need to fit the latest mainline U-Boot, latest mainline Linux kernel, a root filesystem, and a GUI all in this 32MB NOR Flash. This allows the board to boot even without a microSD card (and I can make it function as a basic camera/electronic picture frame in this state, if an non operating system microSD card is installed.) How?My current plan is: disregarding redundancy. U-Boot at address 0 as required by the chip, OpenFirmware device tree at 512kB, Linux kernel zImage at 1MB, a SquashFS4-on-UBI root filesystem hopefully can start at 5MB, and a writable compressed UBIFS overlay file system hopefully can start after 16MB. The root filesystem is an instance of overlayfs, with the writable UBIFS instance laid over the read-only SquashFS4-on-UBI instance.

author: amspire
author_rank: Super Contributor
timestamp: March 22, 2017, 11:21:25 am
content: OpenWRT does a great job with down to 4Mbytes of memory and it has a fairly rich set of lean Linux utilities you can load using the package manager.Not sure what sort of board you need, but you can always just use one of the boards that currently support OpenVPN. There are a few TPlink devices that are around the $20 mark, but the GL.inet devices have more RAM and ROM at a higher price. You get WiFI, 2 Ethernet ports, USB port and microusb port (usually used for power).May be totally unsuitable for you, but it is a system that is all ready to go, along with a development environment to totally re-compile and modify all the software. Very stable.

author: krho
author_rank: Regular Contributor
timestamp: March 22, 2017, 04:30:12 pm
content: licheepi-zero:ducks.What will you use for UI?

author: dgtl
author_rank: Regular Contributor
timestamp: March 22, 2017, 04:44:27 pm
content: Totally doable. I have done systems with (primitive) gui even on 8MB of flash. Look for a decent build system to make your life easier, for example one from herehttp://elinux.org/Build_Systems.Nicer gui systems (ie Qt) are a bit of tight fit for very low-end systems, but framebuffer access is not too complicated; add in libpng and zlib for bitmap images if needed and freetype for fonts and the footprint can be kept very small.

author: poorchava
author_rank: Super Contributor
timestamp: March 22, 2017, 08:11:53 pm
content: I can't help but notice, that the V3s chip is really nice in that, it is in manual-soldering-friendly package and does not require routing the DDR interface. I'm gonna look into it for sure.

author: technix
author_rank: Super Contributor
timestamp: March 23, 2017, 12:22:24 am
content: Quote from: krho on March 22, 2017, 04:30:12 pmIt is not decided yet. Maybe GNUstep (since it is compatible with my usual macOS tools) but it depends on how well it runs on simplefb. My board is a bit larger than LicheePi Zero regardless of the version (SushiBits L in Arduino Mega form factor with reduced pin count, and the SushiBits L Camera is sized to fit a specific 4.3in LCD screen module.)

author: technix
author_rank: Super Contributor
timestamp: March 23, 2017, 03:02:36 am
content: Quote from: poorchava on March 22, 2017, 08:11:53 pmThere is an exposed ground pad in the bottom of the board, but you can just place a giant plated hole there so you can fill solder in after the pins are soldered.

author: technix
author_rank: Super Contributor
timestamp: March 23, 2017, 03:11:37 am
content: Quote from: amspire on March 22, 2017, 11:21:25 amThe challenge here is to fit the latest kernel and tools in there.

author: amspire
author_rank: Super Contributor
timestamp: March 23, 2017, 04:20:27 am
content: Quote from: technix on March 23, 2017, 03:11:37 amJust looked at the Gl.inet box I am running. Kernel is 3.18.23. (Chaos Calmer). OpenWRT tends to change kernels very slowly.

author: technix
author_rank: Super Contributor
timestamp: March 23, 2017, 05:03:43 am
content: Quote from: amspire on March 23, 2017, 04:20:27 amV3s is so new that a set of patches on 4.11-rc (the latest mainline release candidate) is required to drive it...

author: Monkeh
author_rank: Super Contributor
timestamp: March 23, 2017, 05:29:28 am
content: Quote from: technix on March 23, 2017, 05:03:43 amSo it's too new to use any off-the-shelf setup without work - it's also on a new board, so same thing. I don't see the issue here.

author: ali_asadzadeh
author_rank: Super Contributor
timestamp: March 23, 2017, 07:49:46 am
content: I'm an expert in Cortex M, but when It comes to Linux and Cortex A, I'm just a newbie.The V3s is a fantastic chip. the question is How should I start to learn linux and Cortex A?, Also I'm an expert on Altium. I'm wiling to learn and contribute to this project including designing the PCBI hope this would help

author: technix
author_rank: Super Contributor
timestamp: March 23, 2017, 08:42:37 am
content: Quote from: ali_asadzadeh on March 23, 2017, 07:49:46 amYou may want to start playing with Linux on your PC, a virtual machine or Raspberry Pi before touching bringing Linux up on a freshly cooked board.I have the projects on Github, with separate repositories for the hardware, U-Boot, kernel and userland. However the hardware design is being done in EAGLE. If you are willing to contribute I can add you as an collaborator.

author: ali_asadzadeh
author_rank: Super Contributor
timestamp: March 23, 2017, 11:48:59 am
content: Thanks, I'm willing to contribute the Altium files, Also Do you recommended any book or site or youtube channel regarding leaning linux.And what features do you like to have in the PCB, are all decisions made or we can add options?

author: eugenenine
author_rank: Frequent Contributor
timestamp: March 23, 2017, 11:52:48 am
content: Smallest I've done is a 129M CF card. I have an old via mini itx board that booted and ran from the CF card. I didn't do anything special, just used a cd rom drive and installed just the 'A' set of Slackware then anything else that was missing. it didn't fill the card, 128M just happened to be what I had.

author: technix
author_rank: Super Contributor
timestamp: March 23, 2017, 01:25:43 pm
content: Quote from: ali_asadzadeh on March 23, 2017, 11:48:59 amNothing is set in stone yet so features are still up to discussion. Although all the features I have planned have plugged up all I/O pins (except maybe a few) leaving a single I2C bus the only open port. Although you can always add I/O expanders (as I have already added one for an additional SPI bus)

author: ali_asadzadeh
author_rank: Super Contributor
timestamp: March 23, 2017, 04:07:39 pm
content: QuoteOk, fair enough. But I think having USB,WiFi and Ethernet, Camera and LCD should be a most the rest Is not that important, because we can build it like a SMD module too (All the parts on one side of the board). Also I could not find your eagle schematics for V3s on github yet,so that I could do that in Altium too, all the passives could be 0603 or 0805 for easy prototyping too.

author: Sal Ammoniac
author_rank: Super Contributor
timestamp: March 23, 2017, 06:10:27 pm
content: 32MB? That sounds like an infinite amount of FLASH to someone who's used to 128KBor 256KBof FLASH.

author: technix
author_rank: Super Contributor
timestamp: March 24, 2017, 01:07:33 am
content: Quote from: Sal Ammoniac on March 23, 2017, 06:10:27 pmBut I need to fit a bootloader (~300kB,) a Linux kernel (4MB,) a read-only root filesystem (10MB,) and another writable filesystem (16MB) in there.

author: ali_asadzadeh
author_rank: Super Contributor
timestamp: March 24, 2017, 11:20:25 am
content: Maybe we could use BQ24160 as the main power input, it has power path management and can charge a Li-ION battery with configurations from I2C, so the board could have a power scheme like a mobile cell.

author: legacy
author_rank: Super Contributor
timestamp: March 24, 2017, 11:31:41 am
content: Quote from: Sal Ammoniac on March 23, 2017, 06:10:27 pmWell, VxWorks + X11, takes 4MB of ram on my Tektronix X11 terminalYep, ram, the flash takes 200Kbyte for a tftpboot loader, which downloads the kernel + fonts + X11 + WM (simpler than fluxbox) into the ram, and then jumps to it. You can install additional ram through a SIM72-50ns connector, useful if you want to execute a few programs locally (e.g. NetScape? AudioPlayer? the list is very small) instead of remotely.Awesome technology, made in 1994.I dare you to do the same with linux + x11 nowadays

author: technix
author_rank: Super Contributor
timestamp: March 24, 2017, 03:27:17 pm
content: Quote from: ali_asadzadeh on March 24, 2017, 11:20:25 amThe X-Power AXP203 does exactly that. Allwinner CPUs always expect being coupled to an X-Power PMIC and is always sold with one, although technically we can roll with BQ24160.

author: westfw
author_rank: Super Contributor
timestamp: March 26, 2017, 05:24:30 am
content: The smallest Linux distribution I've used was tomsrtbt, which fit on a 1.4M floppy.The first thing it does is decompress itself into ram, of course, and many of the huge and redundant Unix utilities are replaced by busybox. (And it's far from a recent kernel, and x86 rather than arm, but I'd surely hope you can do pretty well with 32x more memory.)

author: nctnico
author_rank: Super Contributor
timestamp: March 26, 2017, 10:15:29 am
content: Quote from: technix on March 22, 2017, 11:02:36 amUse either Buildroot or OpenEmbedded (yocto). I'm finding the latter rather obfustigated so I'm a buildroot user. For a GUI you'll need to select a cut down version of X-windows and some additional tools. IIRC it is possible to get a small root filesystem this way but 32MB may not be enough. If you go for a system without X-windows it is going to be very hard to create a program with a GUI and/or run existing GUI software so having 64MB of flash is going to be worth it.

author: technix
author_rank: Super Contributor
timestamp: March 26, 2017, 12:51:06 pm
content: Quote from: nctnico on March 26, 2017, 10:15:29 amI know that 32MB is definitely a tight fit, that is why the filesystem scheme is compressed UBIFS laid over heavily compressed SquashFS-on-UBI. I may end up forgoing X though, as the SoC does not have DRM support on its graphics hardware.

author: nctnico
author_rank: Super Contributor
timestamp: March 26, 2017, 01:43:01 pm
content: You don't need accellerated graphics to run X-Windows as long as the skin you are using isn't heavy on graphic effects. GTK is pretty versatile when it comes to skins.

author: legacy
author_rank: Super Contributor
timestamp: March 26, 2017, 03:56:19 pm
content: X11 on 32MB ? Simply ridiculous

author: nctnico
author_rank: Super Contributor
timestamp: March 26, 2017, 05:50:58 pm
content: Why? X-Windows has the option to compile a cut down version which is really really small. Less than a decade ago I have used X-Windows on an embedded Linux platform but I can't remember whether the flash was 16MB or 64MB. I think 16MB.

author: alan242
author_rank: Newbie
timestamp: March 26, 2017, 09:08:45 pm
content: Alpine Linux (https://alpinelinux.org) has an ARM distribution and a minirootfs tar. It is built on busybox, the musl C library and uses openrc for init. The current kernel is 4.9.17 so that will need to be replaced with a the custom 4.11-rc kernel. I am not entirely sure the distribution will strip down to for the size limitation. However, the minirootfs tar expands to about 3.5MB. Maybe start with that and add the packages that are needed to see if it will fit?

author: technix
author_rank: Super Contributor
timestamp: March 27, 2017, 01:38:03 am
content: I actually needs udev, dbus and maybe systemd. NetworkManager too. Those packages can be huge...

author: legacy
author_rank: Super Contributor
timestamp: March 27, 2017, 03:39:25 pm
content: Quote from: nctnico on March 26, 2017, 05:50:58 pmit's nanoXQuote from: nctnico on March 26, 2017, 05:50:58 pmWhen Kernel 2.2 were much more smaller, and nanoX was not a part of integration (aka #ifdef ) into X11.Nowadays, dead elephants, especially if compiled with uclibc.

author: legacy
author_rank: Super Contributor
timestamp: March 27, 2017, 03:41:50 pm
content: Quote from: nctnico on March 26, 2017, 05:50:58 pmare you sure it was not directfb? or QTopia (used by SHARP in 2004)?

author: nctnico
author_rank: Super Contributor
timestamp: March 27, 2017, 03:47:39 pm
content: Quote from: legacy on March 27, 2017, 03:41:50 pmNo, definitely X-Windows. It is a bit like the adagio not to use printf if you are space constrained. The funny thing about that is that by the time you are done creating an alternative it will be more bloated than printf. It is quicker and easier to create a mini-printf. It will save space while keeping a very standard API. The same goes for X-Windows. If the regular version is too bloated then compile the minimalistic version. You'll have the same API so most software will work with it.

author: legacy
author_rank: Super Contributor
timestamp: March 27, 2017, 03:58:10 pm
content: directfbcan be compiled with uclibc without problems, and it's small footprint, you can neither say nor do the same with xorg.nanoXwas excellent for the same reason.dude, if you need glibc then binaries and libraries will be 220% bigger at least.

author: technix
author_rank: Super Contributor
timestamp: March 27, 2017, 06:27:50 pm
content: Quote from: legacy on March 27, 2017, 03:58:10 pmThis is interesting... directfb seemed to be a good option for the graphics layer for me.And no I don't need glibc. I know that I will definitely need dbus (NetworkManager as I have Wi-Fi and Bluetooth) and udev (kernel depends on this now) but systemd is still undecided. I don't know if any of those will put a hard requirement on glibc though. If udev and dbus can work with some lightweight libc but systemd depends on glibc, I am going to try use Apple's launchd as the init system as it depends only on POSIX API (I am a full Apple Developer Program enrollee) and start udev and dbus from there.As of the GUI layer, I am investigating creating a display server based on directfb that implements the Cocoa Touch API. The semantics of this device is similar to that of iOS devices, hence this API.

author: calin
author_rank: Regular Contributor
timestamp: April 03, 2017, 06:54:57 am
content: Look @ this -http://tinycorelinux.net/welcome.html

author: cezar
author_rank: Contributor
timestamp: April 04, 2017, 04:24:45 pm
content: OpenWRT?it fits nicely inhttps://www.seeedstudio.com/LinkIt-Smart-7688-p-2573.html