Author Topic: Linux in 32MB Flash  (Read 10087 times)

0 Members and 1 Guest are viewing this topic.

Offline technixTopic starter

  • Super Contributor
  • ***
  • Posts: 3507
  • Country: cn
  • From Shanghai With Love
    • My Untitled Blog
Linux in 32MB Flash
« on: March 22, 2017, 11:02:36 am »
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.
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3802
  • Country: au
Re: Linux in 32MB Flash
« Reply #1 on: March 22, 2017, 11:21:25 am »
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.
 

Offline krho

  • Regular Contributor
  • *
  • Posts: 223
  • Country: si
Re: Linux in 32MB Flash
« Reply #2 on: March 22, 2017, 04:30:12 pm »
licheepi-zero

:ducks.

What will you use for UI?
 

Offline dgtl

  • Regular Contributor
  • *
  • Posts: 183
  • Country: ee
Re: Linux in 32MB Flash
« Reply #3 on: March 22, 2017, 04:44:27 pm »
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 here http://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.
 

Offline poorchava

  • Super Contributor
  • ***
  • Posts: 1672
  • Country: pl
  • Troll Cave Electronics!
Re: Linux in 32MB Flash
« Reply #4 on: March 22, 2017, 08:11:53 pm »
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.
I love the smell of FR4 in the morning!
 

Offline technixTopic starter

  • Super Contributor
  • ***
  • Posts: 3507
  • Country: cn
  • From Shanghai With Love
    • My Untitled Blog
Re: Linux in 32MB Flash
« Reply #5 on: March 23, 2017, 12:22:24 am »
licheepi-zero

:ducks.

What will you use for UI?
It 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.)
« Last Edit: March 23, 2017, 03:06:08 am by technix »
 

Offline technixTopic starter

  • Super Contributor
  • ***
  • Posts: 3507
  • Country: cn
  • From Shanghai With Love
    • My Untitled Blog
Re: Linux in 32MB Flash
« Reply #6 on: March 23, 2017, 03:02:36 am »
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.
There 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.
 

Offline technixTopic starter

  • Super Contributor
  • ***
  • Posts: 3507
  • Country: cn
  • From Shanghai With Love
    • My Untitled Blog
Re: Linux in 32MB Flash
« Reply #7 on: March 23, 2017, 03:11:37 am »
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.
The challenge here is to fit the latest kernel and tools in there.
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3802
  • Country: au
Re: Linux in 32MB Flash
« Reply #8 on: March 23, 2017, 04:20:27 am »
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.
The challenge here is to fit the latest kernel and tools in there.
Just looked at the Gl.inet box I am running. Kernel is 3.18.23. (Chaos Calmer). OpenWRT tends to change kernels very slowly.
 

Offline technixTopic starter

  • Super Contributor
  • ***
  • Posts: 3507
  • Country: cn
  • From Shanghai With Love
    • My Untitled Blog
Re: Linux in 32MB Flash
« Reply #9 on: March 23, 2017, 05:03:43 am »
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.
The challenge here is to fit the latest kernel and tools in there.
Just looked at the Gl.inet box I am running. Kernel is 3.18.23. (Chaos Calmer). OpenWRT tends to change kernels very slowly.
V3s is so new that a set of patches on 4.11-rc (the latest mainline release candidate) is required to drive it...
 

Online Monkeh

  • Super Contributor
  • ***
  • Posts: 7992
  • Country: gb
Re: Linux in 32MB Flash
« Reply #10 on: March 23, 2017, 05:29:28 am »
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.
The challenge here is to fit the latest kernel and tools in there.
Just looked at the Gl.inet box I am running. Kernel is 3.18.23. (Chaos Calmer). OpenWRT tends to change kernels very slowly.
V3s is so new that a set of patches on 4.11-rc (the latest mainline release candidate) is required to drive it...

So 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.
 

Offline ali_asadzadeh

  • Super Contributor
  • ***
  • Posts: 1901
  • Country: ca
Re: Linux in 32MB Flash
« Reply #11 on: March 23, 2017, 07:49:46 am »
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 PCB
I hope this would help :)
ASiDesigner, Stands for Application specific intelligent devices
I'm a Digital Expert from 8-bits to 64-bits
 

Offline technixTopic starter

  • Super Contributor
  • ***
  • Posts: 3507
  • Country: cn
  • From Shanghai With Love
    • My Untitled Blog
Re: Linux in 32MB Flash
« Reply #12 on: March 23, 2017, 08:42:37 am »
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 PCB
I hope this would help :)
You 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.
« Last Edit: March 23, 2017, 09:23:37 am by technix »
 

Offline ali_asadzadeh

  • Super Contributor
  • ***
  • Posts: 1901
  • Country: ca
Re: Linux in 32MB Flash
« Reply #13 on: March 23, 2017, 11:48:59 am »
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?
ASiDesigner, Stands for Application specific intelligent devices
I'm a Digital Expert from 8-bits to 64-bits
 

Offline eugenenine

  • Frequent Contributor
  • **
  • Posts: 865
  • Country: us
Re: Linux in 32MB Flash
« Reply #14 on: March 23, 2017, 11:52:48 am »
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.
 

Offline technixTopic starter

  • Super Contributor
  • ***
  • Posts: 3507
  • Country: cn
  • From Shanghai With Love
    • My Untitled Blog
Re: Linux in 32MB Flash
« Reply #15 on: March 23, 2017, 01:25:43 pm »
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?
Nothing 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)
 

Offline ali_asadzadeh

  • Super Contributor
  • ***
  • Posts: 1901
  • Country: ca
Re: Linux in 32MB Flash
« Reply #16 on: March 23, 2017, 04:07:39 pm »
Quote
Nothing 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)

Ok, 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.
ASiDesigner, Stands for Application specific intelligent devices
I'm a Digital Expert from 8-bits to 64-bits
 

Offline Sal Ammoniac

  • Super Contributor
  • ***
  • Posts: 1668
  • Country: us
Re: Linux in 32MB Flash
« Reply #17 on: March 23, 2017, 06:10:27 pm »
32MB? That sounds like an infinite amount of FLASH to someone who's used to 128KB or 256KB of FLASH.  :-DD
Complexity is the number-one enemy of high-quality code.
 

Offline technixTopic starter

  • Super Contributor
  • ***
  • Posts: 3507
  • Country: cn
  • From Shanghai With Love
    • My Untitled Blog
Re: Linux in 32MB Flash
« Reply #18 on: March 24, 2017, 01:07:33 am »
32MB? That sounds like an infinite amount of FLASH to someone who's used to 128KB or 256KB of FLASH.  :-DD
But I need to fit a bootloader (~300kB,) a Linux kernel (4MB,) a read-only root filesystem (10MB,) and another writable filesystem (16MB) in there.
 

Offline ali_asadzadeh

  • Super Contributor
  • ***
  • Posts: 1901
  • Country: ca
Re: Linux in 32MB Flash
« Reply #19 on: March 24, 2017, 11:20:25 am »
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.
ASiDesigner, Stands for Application specific intelligent devices
I'm a Digital Expert from 8-bits to 64-bits
 

Offline legacy

  • Super Contributor
  • ***
  • !
  • Posts: 4415
  • Country: ch
Re: Linux in 32MB Flash
« Reply #20 on: March 24, 2017, 11:31:41 am »
32MB? That sounds like an infinite amount of FLASH to someone who's used to 128KB or 256KB of FLASH.  :-DD

Well, VxWorks + X11, takes 4MB of ram on my Tektronix X11 terminal :D

Yep, 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 :D
 

Offline technixTopic starter

  • Super Contributor
  • ***
  • Posts: 3507
  • Country: cn
  • From Shanghai With Love
    • My Untitled Blog
Re: Linux in 32MB Flash
« Reply #21 on: March 24, 2017, 03:27:17 pm »
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.
The 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.
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4199
  • Country: us
Re: Linux in 32MB Flash
« Reply #22 on: March 26, 2017, 05:24:30 am »
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.)
 

Online nctnico

  • Super Contributor
  • ***
  • Posts: 26875
  • Country: nl
    • NCT Developments
Re: Linux in 32MB Flash
« Reply #23 on: March 26, 2017, 10:15:29 am »
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?
Use 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.
« Last Edit: March 26, 2017, 10:17:00 am by nctnico »
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 

Offline technixTopic starter

  • Super Contributor
  • ***
  • Posts: 3507
  • Country: cn
  • From Shanghai With Love
    • My Untitled Blog
Re: Linux in 32MB Flash
« Reply #24 on: March 26, 2017, 12:51:06 pm »
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?
Use 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.
I 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.
 

Online nctnico

  • Super Contributor
  • ***
  • Posts: 26875
  • Country: nl
    • NCT Developments
Re: Linux in 32MB Flash
« Reply #25 on: March 26, 2017, 01:43:01 pm »
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.
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 

Offline legacy

  • Super Contributor
  • ***
  • !
  • Posts: 4415
  • Country: ch
Re: Linux in 32MB Flash
« Reply #26 on: March 26, 2017, 03:56:19 pm »
X11 on 32MB ? Simply ridiculous  :-DD :-DD :-DD
 

Online nctnico

  • Super Contributor
  • ***
  • Posts: 26875
  • Country: nl
    • NCT Developments
Re: Linux in 32MB Flash
« Reply #27 on: March 26, 2017, 05:50:58 pm »
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.
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 

Offline alan242

  • Newbie
  • Posts: 4
  • Country: us
Re: Linux in 32MB Flash
« Reply #28 on: March 26, 2017, 09:08:45 pm »
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?
 

Offline technixTopic starter

  • Super Contributor
  • ***
  • Posts: 3507
  • Country: cn
  • From Shanghai With Love
    • My Untitled Blog
Re: Linux in 32MB Flash
« Reply #29 on: March 27, 2017, 01:38:03 am »
I actually needs udev, dbus and maybe systemd. NetworkManager too. Those packages can be huge...
 

Offline legacy

  • Super Contributor
  • ***
  • !
  • Posts: 4415
  • Country: ch
Re: Linux in 32MB Flash
« Reply #30 on: March 27, 2017, 03:39:25 pm »
Why? X-Windows has the option to compile a cut down version which is really really small

it's nanoX

Less than a decade ago

When 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.
 

Offline legacy

  • Super Contributor
  • ***
  • !
  • Posts: 4415
  • Country: ch
Re: Linux in 32MB Flash
« Reply #31 on: March 27, 2017, 03:41:50 pm »
X-Windows on an embedded Linux platform

are you sure it was not directfb? or QTopia (used by SHARP in 2004)?
 

Online nctnico

  • Super Contributor
  • ***
  • Posts: 26875
  • Country: nl
    • NCT Developments
Re: Linux in 32MB Flash
« Reply #32 on: March 27, 2017, 03:47:39 pm »
X-Windows on an embedded Linux platform
are you sure it was not directfb? or QTopia (used by SHARP in 2004)?
No, 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.
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 

Offline legacy

  • Super Contributor
  • ***
  • !
  • Posts: 4415
  • Country: ch
Re: Linux in 32MB Flash
« Reply #33 on: March 27, 2017, 03:58:10 pm »
directfb can be compiled with uclibc without problems, and it's small footprint, you can neither say nor do the same with xorg. nanoX was excellent for the same reason.

dude, if you need glibc then binaries and libraries will be 220% bigger at least.
 

Offline technixTopic starter

  • Super Contributor
  • ***
  • Posts: 3507
  • Country: cn
  • From Shanghai With Love
    • My Untitled Blog
Re: Linux in 32MB Flash
« Reply #34 on: March 27, 2017, 06:27:50 pm »
directfb can be compiled with uclibc without problems, and it's small footprint, you can neither say nor do the same with xorg. nanoX was excellent for the same reason.

dude, if you need glibc then binaries and libraries will be 220% bigger at least.
This 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.
 

Offline calin

  • Regular Contributor
  • *
  • Posts: 238
  • Country: us
Re: Linux in 32MB Flash
« Reply #35 on: April 03, 2017, 06:54:57 am »
 

Offline cezar

  • Contributor
  • Posts: 39
  • Country: gb
Re: Linux in 32MB Flash
« Reply #36 on: April 04, 2017, 04:24:45 pm »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf