Rahix / tbot

Automation/Testing tool for Embedded Linux Development
https://tbot.tools
GNU General Public License v3.0
87 stars 21 forks source link

board.zephyr: add new Zephyr board #29

Open zkrx opened 3 years ago

zkrx commented 3 years ago

I use tbot with Zephyr. I've tried to properly add (basic) Zephyr support and figured I should try upstreaming.

I'm not that good at Python, so this is mainly a big copy and paste with some renaming. I did my best to respect what's in place though :).

For starters: I'm unfortunately testing with an older version of Zephyr (v1.13 vs v2.4.0). I'm not sure how Zephyr's shell evolved since. I've had a look to Zephyr's documentation [1] but I should ideally try to test this on v2.4.0, if I find some time...

I copied what was done for U-Boot and trimmed what I thought wasn't needed: For command execution, I didn't find a way to get the command's return value ("$?"), so I've just removed retval and removed the exec0 and test functions. Also, at least to my knowledge, Zephyr doesn't support environment variables, so this had to go too. I also removed U-Boot-specific stuff such as boot() and ram_base().

In the current state, this PR is missing tc/ and Documentation/ updates (and other stuff that I may have missed).

Also, Zephyr's shell is fairly simple. I've removed the escape function as I don't think it is needed to escape anything, but maybe someone will tell me otherwise?

Do you think there's a chance to merge this? If so, I can try to add what's missing in tc/ and Documentation/ (and other bits you may find lacking).

[1] https://docs.zephyrproject.org/latest/reference/shell/index.html

Rahix commented 3 years ago

Zephyr support does sound very interesting, I definitely support adding that! Though I do have to say that I'm lacking experience here ... Do you know if there's a good way to run a Zephyr demo e.g. in qemu?

Looking at your changeset, it's going in the right direction but as you probably noticed, it needs a lot of additions in different places which isn't too nice (thinking it terms of maintainability). You catched me a bit early with this, as I am currently working on making this entire part more flexible and generic, which would make the zephyr addition much easier. If you'd be okay with relying on your fork for now and giving me a few more weeks, I would suggest waiting for that refactor first. With that in place, this would hopefully get much easier :)

zkrx commented 3 years ago

Do you know if there's a good way to run a Zephyr demo e.g. in qemu?

There is a way to run Zephyr natively with a "Native POSIX" board, see [1]. It seems that you can also emulate ARM (among others) architectures with qemu boards, see [2].

[1] https://docs.zephyrproject.org/latest/boards/posix/native_posix/doc/index.html [2] https://docs.zephyrproject.org/latest/boards/arm/qemu_cortex_m3/doc/index.html

I would suggest waiting for that refactor first

Alright, ping me once it's ready, although it will probably depend on my schedule at that time.

Thanks for checking!

Rahix commented 3 years ago

There is a way to run Zephyr natively with a "Native POSIX" board

Oh, cool, I'll look into that!

Alright, ping me once it's ready, although it will probably depend on my schedule at that time.

Will do! If you're too busy, maybe I can already start moving code from your branch here over to the new system. But let's see ...