Controlling a SIM7600G-H 4G HAT (B) bare metal from the pi zero
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.
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.
Re: Controlling a SIM7600G-H 4G HAT (B) bare metal from the pi zero
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.
Re: Controlling a SIM7600G-H 4G HAT (B) bare metal from the pi zero
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 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
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
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.
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...
No, I can't think of anything funny that won't offend someone if they want it to...
Re: Controlling a SIM7600G-H 4G HAT (B) bare metal from the pi zero
Good point, test as a USB device on standard Linux.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.
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
Raspberries are not Apples or Oranges
Re: Controlling a SIM7600G-H 4G HAT (B) bare metal from the pi zero
Thank you for the reply. That might help a lot.SteveSpencer wrote: ↑Thu Aug 14, 2025 4:11 pmLooking 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.
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
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...
No, I can't think of anything funny that won't offend someone if they want it to...
Return to "Bare metal, Assembly language"
Jump to
- Community
- General discussion
- Announcements
- Other languages
- Deutsch
- Español
- Français
- Italiano
- Nederlands
- 日本語
- Polski
- Português
- Русский
- Türkçe
- User groups and events
- Raspberry Pi Official Magazine
- Using the Raspberry Pi
- Beginners
- Troubleshooting
- Advanced users
- Assistive technology and accessibility
- Education
- Picademy
- Teaching and learning resources
- Staffroom, classroom and projects
- Astro Pi
- Mathematica
- High Altitude Balloon
- Weather station
- Programming
- C/C++
- Java
- Python
- Scratch
- Other programming languages
- Windows 10 for IoT
- Wolfram Language
- Bare metal, Assembly language
- Graphics programming
- OpenGLES
- OpenVG
- OpenMAX
- General programming discussion
- Projects
- Networking and servers
- Automation, sensing and robotics
- Graphics, sound and multimedia
- Other projects
- Media centres
- Gaming
- AIY Projects
- Hardware and peripherals
- Camera board
- Compute Module
- Official Display
- HATs and other add-ons
- Device Tree
- Interfacing (DSI, CSI, I2C, etc.)
- Keyboard computers (400, 500, 500+)
- Raspberry Pi Pico
- General
- SDK
- MicroPython
- Other RP2040 boards
- Zephyr
- Rust
- AI Accelerator
- AI Camera - IMX500
- Hailo
- Software
- Raspberry Pi OS
- Raspberry Pi Connect
- Raspberry Pi Desktop for PC and Mac
- Beta testing
- Other
- Android
- Debian
- FreeBSD
- Gentoo
- Linux Kernel
- NetBSD
- openSUSE
- Plan 9
- Puppy
- Arch
- Pidora / Fedora
- RISCOS
- Ubuntu
- Ye Olde Pi Shoppe
- For sale
- Wanted
- Off topic
- Off topic discussion