We use some essential cookies to make our website work.

We use optional cookies, as detailed in our cookie policy, to remember your settings and understand how you use our website.

7 posts • Page 1 of 1
Onekx_
Posts: 2
Joined: Wed Aug 13, 2025 4:24 pm

Controlling a SIM7600G-H 4G HAT (B) bare metal from the pi zero

Wed Aug 13, 2025 5:12 pm

I want to get into doing bare metal things with the raspberry pi zero but have essentially no experience with bare metal programming. One of the things I recently bought for the pi is this waveshare modem: https://www.waveshare.com/sim7600g-h-4g-hat-b.htm

I found this tutorial for bare metal programming on the zero: https://github.com/dwelch67/raspberrypi-zero

My thought processes was:

The waveshare modem supports UART, tho it only has usb ports.

Apparently bare metal usb is complicated.

The tutorial shows how to do UART and its relatively straightforward.

There are UART to usb converters.

Therefore i can just control the modem with UART by connecting the usb-uart bridge’s uart side to the relevant gpio pins on the pi and plugging the usb into the waveshare modem.


With the waveshare still on the way I did some further reading and thinking and I realised that my initial idea may be very naive. As you can probably tell my understanding of usb is quite limited but as far as I know there is a difference between usb hosts and clients. When connecting a usb-uart bridge to a pc to talk to the pi over uart, it’s probably the pc that acts as a host and the bridge as client. When controlling the waveshare modem from a serial terminal on a pc it’s probably again the pc acting as host and the modem acting as client. So possibly my idea is not going to work because both the bridge and the modem expect to act as client.

So really my question is if my initial plan is going to work, and if not, what to do instead.
Maybe implementing bare metal serial over usb is not that difficult after all?

I would appreciate it a lot if someone could correct my assumptions on this.

Thank you in advance.

pmoore
Posts: 61
Joined: Thu Jun 28, 2018 9:53 am

Re: Controlling a SIM7600G-H 4G HAT (B) bare metal from the pi zero

Thu Aug 14, 2025 11:44 am

AIUI, if you are able to implement a driver for SIM7600G-H in https://github.com/rsta2/circle/tree/master/lib/usb then you would be well on your way to accomplishing your goal, directly over USB. ChatGPT-5 / Grok 4 / Claude Code might be able to help guide you through the process a little. Circle is a (fantastic) C++ library for developing bare metal projects on the raspberry pi. It would take care of many of the USB abstractions for you.

Gavinmc42
Posts: 8346
Joined: Wed Aug 28, 2013 3:31 am

Re: Controlling a SIM7600G-H 4G HAT (B) bare metal from the pi zero

Thu Aug 14, 2025 11:58 am

Interesting hat, DIY Pi phone?

I just installed USBBoot so I can do more baremetal Zero coding.
I tend to use Ultibo, have not tried Circle for years.

USBboot uses the USB port as a bootloader, that might conflict with this hat's USB pogo pins.
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

SteveSpencer
Posts: 667
Joined: Thu Mar 28, 2013 9:19 am

Re: Controlling a SIM7600G-H 4G HAT (B) bare metal from the pi zero

Thu Aug 14, 2025 4:11 pm

Looking at the WIKI pages for the product, it enumerates as COM ports. The one providing the AT interface may well be a generic CDC-style thing.
It may well be that in that instance, you don't need a driver for Circle, as it will already be supported.

Having played with various USB devices with Circle, my suggestion would be to connect the board to a regular device running "normal" linux, and see what lsusb tells you about it; that's usually a good starting point.
Steve S
No, I can't think of anything funny that won't offend someone if they want it to...

Gavinmc42
Posts: 8346
Joined: Wed Aug 28, 2013 3:31 am

Re: Controlling a SIM7600G-H 4G HAT (B) bare metal from the pi zero

Thu Aug 14, 2025 11:38 pm

Having played with various USB devices with Circle, my suggestion would be to connect the board to a regular device running "normal" linux, and see what lsusb tells you about it; that's usually a good starting point.
Good point, test as a USB device on standard Linux.
Baremetal code could be tested under Linux before porting to Circle?

i have found Linux apps tend to use external libs, which make for interesting dependencies.
Most Linux apps probably use libusb so you would need an equiv or to compile that for baremetal.

Developing code on a Zero is a bit harder than a B+ which can use Ethernet for kernel updates.

I have also used QEMU to run baremetal code.
Have not tried on my latest Pi5's but I did get 7 baremetal VMs running on QEMU on a Pi400.
USB pass though on QEMU?

Developing baremetal stuff is a lot of code, test, edit, compile cycles, adding SD card flashing to that cycle does slow things down.

Zeros are not powerful so Linux is a bit of a dog, I use TinyCore Linux for the older Pi's as it is much smaller.
You might find it useful as a interim step from between Debian to Baremetal.
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

Onekx_
Posts: 2
Joined: Wed Aug 13, 2025 4:24 pm

Re: Controlling a SIM7600G-H 4G HAT (B) bare metal from the pi zero

Sun Aug 17, 2025 1:07 pm

SteveSpencer wrote:
Thu Aug 14, 2025 4:11 pm
Looking at the WIKI pages for the product, it enumerates as COM ports. The one providing the AT interface may well be a generic CDC-style thing.
It may well be that in that instance, you don't need a driver for Circle, as it will already be supported.

Having played with various USB devices with Circle, my suggestion would be to connect the board to a regular device running "normal" linux, and see what lsusb tells you about it; that's usually a good starting point.
Thank you for the reply. That might help a lot.

I have seen circle already has built in support for cdc over usb. Out of interest, how difficult do you think it is reverse engineer that by reading the documentation and looking at the packets with a usb traffic analyser?

SteveSpencer
Posts: 667
Joined: Thu Mar 28, 2013 9:19 am

Re: Controlling a SIM7600G-H 4G HAT (B) bare metal from the pi zero

Fri Aug 22, 2025 12:35 pm

Onekx_ wrote:
Sun Aug 17, 2025 1:07 pm
I have seen circle already has built in support for cdc over usb. Out of interest, how difficult do you think it is reverse engineer that by reading the documentation and looking at the packets with a usb traffic analyser?
I guess it depends on how much you already know about USB protocols...
I wouldn't attempt it, on the well-tried "If it ain't broke" principle.
Steve S
No, I can't think of anything funny that won't offend someone if they want it to...

7 posts • Page 1 of 1

Return to "Bare metal, Assembly language"

AltStyle によって変換されたページ (->オリジナル) /