Compile programs for the Raspberry Pi 1 and Zero's ARMv6 SoC
I was wondering how I can compile C++ programs for the original Pi and Pi Zero's ARMv6 SoC. According to https://chromium.googlesource.com/chrom ... ium_arm.md you can compile Chromium for ARM which I'd like to do because the Chromium build on Raspbian is out of date. But how do I compile Chromium for ARMv6 rather than ARMv7 so that it runs on all Pi models? Should I use https://packages.debian.org/stretch/gcc ... -gnueabihf
Ubuntu 18.04 LTS desktop images for the Raspberry Pi 3.
https://github.com/CodeExecution/Ubuntu-ARM64-RPi
https://github.com/CodeExecution/Ubuntu-ARM64-RPi
Re: Compile programs for the Raspberry Pi 1 and Zero's ARMv6 SoC
Pretty simple, if you compile on a Raspberry 1B+ with the defaults it will build for the ARMv6.
RPi = The best ARM based RISC OS computer around
More than 95% of posts made from RISC OS on RPi 1B/1B+ computers. Most of the rest from RISC OS on RPi 2B/3B/3B+ computers
More than 95% of posts made from RISC OS on RPi 1B/1B+ computers. Most of the rest from RISC OS on RPi 2B/3B/3B+ computers
Re: Compile programs for the Raspberry Pi 1 and Zero's ARMv6 SoC
Chromium recommends you cross-compile for ARM because most ARM devices lack the RAM and power to build Chromium directly. For a 512MB ARMv6 SBC, I agree with this. How do I cross compile for ARMv6?
Ubuntu 18.04 LTS desktop images for the Raspberry Pi 3.
https://github.com/CodeExecution/Ubuntu-ARM64-RPi
https://github.com/CodeExecution/Ubuntu-ARM64-RPi
Re: Compile programs for the Raspberry Pi 1 and Zero's ARMv6 SoC
Have you actually tried it?
Slowness is the problem, but for a one-off build, you will spend much longer trying to set up the cross compile.
You can compile huge projects on the Zero. It takes a few hours, but it does work. You can leave it running overnight.
Increasing the swap file size will help it through any brief periods when memory is over committed.
Code: Select all
sudo sed -i 's/^CONF_SWAPSIZE=[0-9]*$/CONF_SWAPSIZE=1024/' /etc/dphys-swapfile
sudo /etc/init.d/dphys-swapfile restart
Re: Compile programs for the Raspberry Pi 1 and Zero's ARMv6 SoC
I doubt it will work directly on any Pi, I am likely to get the following error when building:
This is because of lack of RAM. See https://chromium.googlesource.com/chrom ... er-Crashes
Code: Select all
collect2: ld terminated with signal 6 Aborted terminate called after throwing an instance of 'std::bad_alloc'
collect2: ld terminated with signal 11 [Segmentation fault], core dumped
Ubuntu 18.04 LTS desktop images for the Raspberry Pi 3.
https://github.com/CodeExecution/Ubuntu-ARM64-RPi
https://github.com/CodeExecution/Ubuntu-ARM64-RPi
Re: Compile programs for the Raspberry Pi 1 and Zero's ARMv6 SoC
That would mean the linker is needing more than 2GB of memorycode_exec wrote: ↑Fri Dec 07, 2018 4:16 pmI doubt it will work directly on any Pi, I am likely to get the following error when building:
This is because of lack of RAM. See https://chromium.googlesource.com/chrom ... er-CrashesCode: Select all
collect2: ld terminated with signal 6 Aborted terminate called after throwing an instance of 'std::bad_alloc' collect2: ld terminated with signal 11 [Segmentation fault], core dumped

Perhaps look at the "--no-keep-memory" linker option.
Code: Select all
--no-keep-memory
ld normally optimizes for speed over memory usage by caching the symbol tables of
input files in memory. This option tells ld to instead optimize for memory usage, by
rereading the symbol tables as necessary. This may be required if ld runs out of
memory space while linking a large executable.
Re: Compile programs for the Raspberry Pi 1 and Zero's ARMv6 SoC
I'd rather cross-compile rather than compile directly on a Pi. Even if it did work, it would take ages (probably a few days) it took eight hours to compile x64 Chromium on a laptop with 4 cores and 8GB RAM!jahboater wrote: ↑Fri Dec 07, 2018 5:57 pmThat would mean the linker is needing more than 2GB of memorycode_exec wrote: ↑Fri Dec 07, 2018 4:16 pmI doubt it will work directly on any Pi, I am likely to get the following error when building:
This is because of lack of RAM. See https://chromium.googlesource.com/chrom ... er-CrashesCode: Select all
collect2: ld terminated with signal 6 Aborted terminate called after throwing an instance of 'std::bad_alloc' collect2: ld terminated with signal 11 [Segmentation fault], core dumped
Perhaps look at the "--no-keep-memory" linker option.Code: Select all
--no-keep-memory ld normally optimizes for speed over memory usage by caching the symbol tables of input files in memory. This option tells ld to instead optimize for memory usage, by rereading the symbol tables as necessary. This may be required if ld runs out of memory space while linking a large executable.
Ubuntu 18.04 LTS desktop images for the Raspberry Pi 3.
https://github.com/CodeExecution/Ubuntu-ARM64-RPi
https://github.com/CodeExecution/Ubuntu-ARM64-RPi
Re: Compile programs for the Raspberry Pi 1 and Zero's ARMv6 SoC
Agreed. I wish there were a simple, obvious, well-documented and easily downloadable cross-compiler toolchain available (for compiling Pi stuff on a regular computer).I'd rather cross-compile rather than compile directly on a Pi. Even if it did work, it would take ages (probably a few days) it took eight hours to compile x64 Chromium on a laptop with 4 cores and 8GB RAM!
Note that the stopgap - half-way there - solution is a cross-compiler toolchain that allows you to compile for the PiZero on a regular (3B-ish) Pi.
"L'enfer, c'est les autres"
G fytc hsqr rum umpbq rm qyw rm rfc kmbq md rfgq dmpsk:
Epmu Sn!
J lnacjrw njbruh-carppnanm vxm rb mnuncrwp vh yxbcb!
G fytc hsqr rum umpbq rm qyw rm rfc kmbq md rfgq dmpsk:
Epmu Sn!
J lnacjrw njbruh-carppnanm vxm rb mnuncrwp vh yxbcb!
Re: Compile programs for the Raspberry Pi 1 and Zero's ARMv6 SoC
There are advantages of using more powerful computers for compiling, though as you are talking about a desktop application the reasonable thing is to compile it on the desktop computer on which it will run, if it takes to long then blame the maintainers for there error of creating something of no use to human beings running reasonable systems.
I personally have a rule, that if it takes more than 4 hours to build on my current primarry RISC OS system it is to big to be of use, on any system. That includes for Linux stuff (if it will run RISC OS it will run Linux). This is part of why I like TCC even though TCC does not do any real optimization. I have thought about writing a simple pre-processor that would do some basic simple algorithmic optimization, and a peep-hole post compile optimizer for use with TCC, though probably will not do the first (I believe strongly in the philosophy that a programmer is responcible for providing the most effecient implementation of an algorithm, so high level profiling optimization is wasted code in a compiler).
I personally have a rule, that if it takes more than 4 hours to build on my current primarry RISC OS system it is to big to be of use, on any system. That includes for Linux stuff (if it will run RISC OS it will run Linux). This is part of why I like TCC even though TCC does not do any real optimization. I have thought about writing a simple pre-processor that would do some basic simple algorithmic optimization, and a peep-hole post compile optimizer for use with TCC, though probably will not do the first (I believe strongly in the philosophy that a programmer is responcible for providing the most effecient implementation of an algorithm, so high level profiling optimization is wasted code in a compiler).
RPi = The best ARM based RISC OS computer around
More than 95% of posts made from RISC OS on RPi 1B/1B+ computers. Most of the rest from RISC OS on RPi 2B/3B/3B+ computers
More than 95% of posts made from RISC OS on RPi 1B/1B+ computers. Most of the rest from RISC OS on RPi 2B/3B/3B+ computers
-
- Posts: 92
- Joined: Fri Jan 10, 2014 8:31 am
Re: Compile programs for the Raspberry Pi 1 and Zero's ARMv6 SoC
Just pass-march=armv6 to gcc compilation arguments. I'm doing this all the time (compiling on a Pi2, running on a Pi1)
If you want to be sure, maybe you can add -mfpu=vfp and -mfloat-abi=hard too.
You can patch CFLAGS variable in the Makefile or something like this, depending on the project.
This is not crosscompilation, as long as the broad architecture is the same, it's just a slightly different (older, in this case) instruction set.
If you want to be sure, maybe you can add -mfpu=vfp and -mfloat-abi=hard too.
You can patch CFLAGS variable in the Makefile or something like this, depending on the project.
This is not crosscompilation, as long as the broad architecture is the same, it's just a slightly different (older, in this case) instruction set.
Re: Compile programs for the Raspberry Pi 1 and Zero's ARMv6 SoC
I use:
to specify the CPU exactly.
If your GCC is recent enough:also works.
Code: Select all
-mcpu=arm1176jzf-s -mfpu=vfp
If your GCC is recent enough:
Code: Select all
-march=native -mtune=native