usbarmory / tamago

TamaGo - ARM/RISC-V bare metal Go
BSD 3-Clause "New" or "Revised" License
1.35k stars 52 forks source link

add Raspberry Pi 1 support #13

Closed prusnak closed 3 years ago

prusnak commented 4 years ago

This PR adds Raspberry Pi 1 (B+) support to Tamago.

It's an amalgamation of Pi Zero and Pi 2 code.

Tested on Raspberry Pi 1 B+ v1.2 via https://github.com/prusnak/tamago-example-pi1, which is a slightly modified version of https://github.com/kenbell//tamago-example-pi2 (the only diff is the latest commit)

kenbell commented 4 years ago

Nice

The ramSize is getting a bit messy. For Pi, I think there's a way we can interrogate the VideoCore for the actual available RAM. As a separate change, I'll take a look if there's a way to hook that in sufficiently early in the startup sequence.

prusnak commented 4 years ago

I did some more testing with Raspberry Pi 1 A (not A+) and Pi 1 B (not B+) and here are the results:

Raspberry Pi 1 B+ I used for the initial testing works flawlessly.

Update: Activity LEDs on Pi 1 A and Pi 1 B are connected to the GPIO line 16 (0x10), while Power LED cannot be controlled via the CPU at all.

I am not sure whether it's worth complicating the PR to support these discontinued and unsupported boards (according to Wikipedia only A+ and B+ are supported and will be in production until January 2026). I am not adding these non-plus variants into the README.md, but I left two comments in led.go in case someone really needs this anyway:

abarisani commented 4 years ago

An alternative to introduce a lot of new code to query available RAM could also be to have different mem.go depending on a build tag which specifies the actual model. This might be cleaner, simpler and introduce less code.

abarisani commented 4 years ago

If all LEDs are always going to be treated identically by each model, wouldn't it be better to move the functions repeated in pizero, pi2 and pi1 to the pi package and have each model-specific Init just initialize the list of available names, numbers ? This would also simplify the need for the Board type which at the moment only supports the LED functions. This came up while reviewing this as there is yet another repetition for those functions. Thoughts @kenbell ?

abarisani commented 4 years ago

Any thoughts on my comment?

kenbell commented 3 years ago

@abarisani - With the Pi, the user can change the ratio of RAM for the ARM CPUs vs the GPU using the config.txt file read by the firmware: https://www.raspberrypi.org/documentation/configuration/config-txt/memory.md

I don't know if supporting that entirely makes sense in tamago use-cases, but it's something that could conflict with setting fixed values for the ARM RAM available.

abarisani commented 3 years ago

I'd like to merge this but I'd need it to target development and not master so that we can stage it in that branch first, thanks!

prusnak commented 3 years ago

Rebased on top of development branch

abarisani commented 3 years ago

This is now also merged in master. Thanks for your contribution!