handmade.network » Forums » How to start hardware programming
msmshazan
Shazan Shums
162 posts

Some day I will make quality software.
Programming FTW.

#11196 How to start hardware programming
7 months, 2 weeks ago Edited by Shazan Shums on March 7, 2017, 2:40 a.m.

Last week I wa playing shenzenio a game about hardware programming. so I wanted to try it for real. so any idea on how to start. The internet says use arduino but it doesn't give the low level feeling. So any advice from hardware programmers.

Just being curious on programming....
AsafG
Asaf Gartner
29 posts
#11197 How to start hardware programming
7 months, 2 weeks ago

The Arduino uses an off-the-shelf ATmega chip. You can buy these for a few dollars each without the rest of the Arduino board. They may come with or without the Arduino bootloader already flashed.
In any case, you can flash them yourself with your custom software. You need to build a fairly simple circuit, hook it up to your computer's serial port (or USB adapter), and flash it using Atmel's software.
They have some competitors. For example, you could get a PIC microcontroller. I never used one, but I assume the process is mostly the same: build the flashing circuit and use the manufacturer's compiler and flashing software.
To be honest, for the most part it's just more busy work compared to using an Arduino, with very little benefit. You'll be able to flash slightly larger programs (since you don't use the Arduino's bootloader), but it's not really going to teach you much about the hardware.

You can go more low-level than that, but you'll need to have a project in mind before you go and buy components.

You may be interested in Ben Eater's work, who was mentioned in Abner's education update.
mmozeiko
Mārtiņš Možeiko
1485 posts
1 project
#11198 How to start hardware programming
7 months, 2 weeks ago Edited by Mārtiņš Možeiko on March 7, 2017, 3:38 a.m.

What do you mean when you say "hardware programming" ?

If it just about writing assembly and doing some input/output to devices then you can do that on desktop with x86 assembly. Write a bootsector or uefi loader that loads your kernel and then does whatever it wants. As a bonus its super easy to test it - there are several of emulators (qemu, bochs), or even full VM's (qemu, VirtualBox, VMWare, ...) that can help a lot to start this process. Or you can do almost same on raspberry pi & ARM. Or probably also on Arduino, I don't know anything about arduino.

Or are you talking about creating actual hardware? By connecting bunch of chips together? Like Big Mess o' Wires.
Todd
94 posts

I use x86-64 assembly, Python, C, and SQL to fight malware.

#11267 How to start hardware programming
7 months, 2 weeks ago

You could get a TI Launchpad like the MSP430 for pretty cheap as well. I have 2 of them... But haven't found the time to program them yet! But they can be programmed with C and assembly.

Ummm, and as Martins said, shoot, just do it with your computer... That's what I do since I'm doing reverse engineering now, by the time I get to my TI chips, I'll at least be more comfortable with low-level programming that way.

I'm the smartest man in Athens because I know that I know nothing. ~ Socrates
msmshazan
Shazan Shums
162 posts

Some day I will make quality software.
Programming FTW.

#11331 How to start hardware programming
7 months, 1 week ago

How to start x86 assembly programming. I only know that it is possible to inline assembly in 32bit not in 64bit.
And is the boot sector stuff done in 16bit. Can you provide links on how to start x86 assembly programming?

Just being curious on programming....
mmozeiko
Mārtiņš Možeiko
1485 posts
1 project
#11332 How to start hardware programming
7 months, 1 week ago Edited by Mārtiņš Možeiko on March 16, 2017, 4:13 a.m.

You easily do 64-bit inline-assembly in gcc/clang: https://godbolt.org/g/0AtsX3

But if you really want to use Microsoft toolchain, you can still do it separate .asm files.

As for boot sectors - if we talk about x86 PC, then don't bother with them. All modern systems now support UEFI. UEFI is so much more better than old MBR bootloaders. Typically for it you just write C or C++ code, compile to special .exe file (with .EFI extension) and put it special folder in FAT partition. Then BIOS will be able to boot it, no need to bother with 16-bit code or bootsectors. You can still write UEFI loader in assembly, if you want. But it's not required.

Here's "Hello world" example for UEFI loader: https://mjg59.dreamwidth.org/18773.html?thread=767573
Here's a bit more advanced example, that accesses graphics system: https://github.com/tqh/efi-example
You can access a lot of stuff in UEFI - disks, usb, network, even graphics! Yes, you can blit graphics to screen from UEFI bootloader ;)

Here are some other guides on it:
https://github.com/tianocore/tian...tarted-Writing-Simple-Application
http://x86asm.net/articles/uefi-programming-first-steps/