Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
Rescue Toaster
Mar 13, 2003
What's the best way to start learning the linux kernel, especially in regards to device driver development. Something like Raspberry Pi? Beagle Board Black? Something I could like... hook up a SPI device and provide a /dev/ for it would be the sort of platform I'm looking to start with.

Adbot
ADBOT LOVES YOU

Tiger.Bomb
Jan 22, 2012

Rescue Toaster posted:

What's the best way to start learning the linux kernel, especially in regards to device driver development. Something like Raspberry Pi? Beagle Board Black? Something I could like... hook up a SPI device and provide a /dev/ for it would be the sort of platform I'm looking to start with.

Both should fit what you'd like to do well. There's a youtube channel that's supposed to be good with tutorials on BeagleBone stuff. http://derekmolloy.ie/beaglebone/

Delta-Wye
Sep 29, 2005

Rescue Toaster posted:

What's the best way to start learning the linux kernel, especially in regards to device driver development. Something like Raspberry Pi? Beagle Board Black? Something I could like... hook up a SPI device and provide a /dev/ for it would be the sort of platform I'm looking to start with.

As long as the Linux kernel has decent support for the SoC it shouldn't really matter. I've had to do a bunch of patch backporting to get GPIO, power management and a few other features working correctly on a gumstix board.

I suppose that's one way to start learning the linux kernel though :getin:

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!
Can somebody confirm for me that there isn't really a turn-key solution for interfacing with SPI in Python with the Raspberry Pi? I see some people have written wrappers, which I will be trying, but I was hoping by now there was something standard and blessed.

Delta-Wye
Sep 29, 2005

Rocko Bonaparte posted:

Can somebody confirm for me that there isn't really a turn-key solution for interfacing with SPI in Python with the Raspberry Pi? I see some people have written wrappers, which I will be trying, but I was hoping by now there was something standard and blessed.

Have you tried to read and write directly from /dev/spi with the normal file handling functionality?

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!

Delta-Wye posted:

Have you tried to read and write directly from /dev/spi with the normal file handling functionality?
I didn't have a handle for it in /dev/spi. Actually it looks like SPI is kind of the shady area of the Raspberry Pi, which makes me sad. There also doesn't appear to be a Python3-friendly module for SPI interaction that would work on the Raspberry Pi. At best I eventually got a spidev wrapper working in Python2 enough to light an LED on and off if I told it to just transmit piles of 0xFF's and 0x00's alternately. I couldn't get anything coherent out of this MCP3008 ADC package I was trying to test with a potentiometer. There's some C code out there so I am thinking I have to drop down into C-land and try ioctl or making my own driver; the Python honeymoon ended pretty quick.

Delta-Wye
Sep 29, 2005

Rocko Bonaparte posted:

I didn't have a handle for it in /dev/spi. Actually it looks like SPI is kind of the shady area of the Raspberry Pi, which makes me sad. There also doesn't appear to be a Python3-friendly module for SPI interaction that would work on the Raspberry Pi. At best I eventually got a spidev wrapper working in Python2 enough to light an LED on and off if I told it to just transmit piles of 0xFF's and 0x00's alternately. I couldn't get anything coherent out of this MCP3008 ADC package I was trying to test with a potentiometer. There's some C code out there so I am thinking I have to drop down into C-land and try ioctl or making my own driver; the Python honeymoon ended pretty quick.

There is nothing wrong with C (:getin:), but Python can do ioctl calls.

EDIT: Although if the hw support is poo poo, you're hosed either way. I'm always surprised how terrible the software support for SoCs seems to be. Developing one is expensive enough, I'm surprised it isn't worth hiring a coder to knock out the necessary kernel parts for rock-solid support.

Delta-Wye fucked around with this message at 05:08 on Dec 20, 2013

yippee cahier
Mar 28, 2005

I am using a bare metal Atmel Cortex M4 device at work and want to quit maintaining and using the standalone bootloader that some previous developer made.

The chip has a bootloader in ROM that we can use to recover the device in case anything goes wrong with the fancy application based update program. I want to write a super stripped down program that I can copy from internal flash to RAM and jump to well after the system is up and running and the new firmware image is verified. This is because a) I'll be rewriting internal flash and b) we're really starved for RAM. The update program will get the new image out of external flash and write it to internal flash before performing a reset. What's the best strategy for this? Do I compile this program with -fpic and -nostdlib separate from the rest of my main application program, then load it to a special section of my main program's flash with the linker script, then write a little wrapper to do the load and execution in my main program code? Does this even make sense?

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!

Delta-Wye posted:

There is nothing wrong with C (:getin:), but Python can do ioctl calls.

EDIT: Although if the hw support is poo poo, you're hosed either way. I'm always surprised how terrible the software support for SoCs seems to be. Developing one is expensive enough, I'm surprised it isn't worth hiring a coder to knock out the necessary kernel parts for rock-solid support.
Once I saw that Raspberry Pi comes with SPI and I2C disabled by default in Raspian--and possibly the other distros that are part of the NOOB thing--I got worried. I don't really have a problem with C; I particularly do C++ for home stuff. I just figured I could rapidly prototype some stuff in Python, but if I have to trudge through some low-level details that take as much code to write in Python than C, or possibly even more lines of code in Python, then I might as well just go all the way. I had gotten the Raspberry Pi on that initial, damaged notion that I could use higher-level toolchains with it. Granted, I guess I'm still getting to use a mature C/C++ toolchain instead of one vendor-specific thing that doesn't implement any real standard correctly.

It's just alarming to me to think that people just bit bang with the Raspberry Pi and call it a day. My impression was that it didn't have ADCs, motor controllers, or anything like that, but at least it had SPI and I2C for expansion. Seeing the modules to drive them not even being loaded by default kind of gives me pause. But no matter, I'll get this MCP3008 to listen to me one way or another.

Bad Munki
Nov 4, 2008

We're all mad here.


Post a trip report when you get a satisfactory solution. I haven't run into it yet so I haven't even bothered to look, but I do have some projects in mind where SPI and I2C would be critical factors.

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!

Bad Munki posted:

Post a trip report when you get a satisfactory solution. I haven't run into it yet so I haven't even bothered to look, but I do have some projects in mind where SPI and I2C would be critical factors.
My inspiration to switch to C or C++ came from here:
http://hertaville.com/2013/07/24/interfacing-an-spi-adc-mcp3008-chip-to-the-raspberry-pi-using-c/

I was surprised but this actually worked the very first time. It compiled and ran without a single bitch or moan, and it looks like I had my MCP3008 hooked up correctly.

On the Python side, I'm perhaps unrealistically bitchy because it looks like all the good libraries for SPI require Python2, where I was trying to use Python3 for everything. Particularly I had set myself up with QT4 with Python3 and was hoping to bring up a GUI to show things. I'm now assuming that EE stuff with Python in the world at large it stuck in Python2, and usually not even Python 2.7. I tried to interface with spidev, but whatever I was using was just generating bullshit. I'll have to really review the source in that hertaville tutorial and make sure I actually understand SPI. I actually never worked with it before, and kind of assumed that since there were two chip select pins, that I could potentially control 4 chips. :doh: I don't have a reason to do that, and I know one can do some things to expand things out (as simple as a mux), but I'm just saying I was ignorant even walking into it.

I guess if I were a big boy I would set up Boost.Python or something and write some good Python3 bindings for spidev and publish it. Actually, I'm kind of giggling in my head at the thought of trying to set up the Boost toolchain to do all that and have the result actually run on a Pi. :bang:

I have some stuff here that's technically I2C so later next week I'll probably start playing with that once I know a little more about what I'm talking about. I kind of bought a bunch of random crap to see what it was like interfacing with all this stuff.

yippee cahier
Mar 28, 2005

It looks like that mcp3008Spi class is a pretty thin wrapper around a couple ioctl and open/close calls. You could rewrite that in pure python pretty easily.

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!

sund posted:

It looks like that mcp3008Spi class is a pretty thin wrapper around a couple ioctl and open/close calls. You could rewrite that in pure python pretty easily.
Maybe, but it's baby's first ioctl here. I can see that easily enough, but how do I handle native open/close calls? Deciphering and translating the proper ioctl values looks like a hoot though. The code I was referencing does drop into spidev's headers, and it's full of things like SPI_IOC_MAGIC, which is apparently the 'k' character.

yippee cahier
Mar 28, 2005

Rocko Bonaparte posted:

Maybe, but it's baby's first ioctl here. I can see that easily enough, but how do I handle native open/close calls? Deciphering and translating the proper ioctl values looks like a hoot though. The code I was referencing does drop into spidev's headers, and it's full of things like SPI_IOC_MAGIC, which is apparently the 'k' character.

Yeah, the docs for Python's fnctl module aren't exactly reassuring, but I'm sure there are examples out there. It looks like you can pass Python's ioctl the file object returned by open(). Wrap it all up in a class and you're good to go.

I might find some time at work to see how well a Python C parser module works for another project and can report back if you think it might be of use for getting definitions out of the spidev header automatically. You can probably just dive in there by hand and get what you need for this project though.

Hyvok
Mar 30, 2010
Does anyone have any ideas on how to implement some kind of GUI to run on an ARM and a graphical color LCD screen?

I can basically think of "make your own" (quite a bit of work creating all the required GUI framework stuffs) and "install linux" which is in my opinion a bit too bloaty for a simple GUI. Is there any middle ground? I wouldn't need an actual OS or anything, just display some graphs and have some buttons and stuff like that.

FSMC
Apr 27, 2003
I love to live this lie

Hyvok posted:

Does anyone have any ideas on how to implement some kind of GUI to run on an ARM and a graphical color LCD screen?

I can basically think of "make your own" (quite a bit of work creating all the required GUI framework stuffs) and "install linux" which is in my opinion a bit too bloaty for a simple GUI. Is there any middle ground? I wouldn't need an actual OS or anything, just display some graphs and have some buttons and stuff like that.

I just made my own GUI, but there are some basic GUI's out there for some ARM chips. If you get one of these cheap STM32 boards from ebay they usually come with a some software. A quick check brought up something like ucos-II.

Zuph
Jul 24, 2003
Zupht0r 6000 Turbo Type-R
NXP and STM ship binary versions of the emWin graphics library. I haven't used it myself, but it looks pretty decent.

Whatever you do, stay miles away from those lovely 4D Systems Displays. Never again.

My Rhythmic Crotch
Jan 13, 2011

If anyone is doing development with the nRF51822, let me save you some time and frustration: v5 of the SDK requires v6 of their BLE "softDevice" - and v6 is still in beta so you will have to poke around a bit to find it. The device will hang trying to bring up the BLE stack if you have the older version of the softDevice installed.

Other than that, this chip looks awesome and I'm pumped to get going with it.

Edit for one more tip: If you are using OS X and having difficulty connecting to the onboard Segger J-Link, you will need to do this first.

My Rhythmic Crotch fucked around with this message at 23:55 on Dec 21, 2013

My Rhythmic Crotch
Jan 13, 2011

Rescue Toaster posted:

What's the best way to start learning the linux kernel, especially in regards to device driver development. Something like Raspberry Pi? Beagle Board Black? Something I could like... hook up a SPI device and provide a /dev/ for it would be the sort of platform I'm looking to start with.
I've written a driver for Linux that allows you to display text on a small graphical LCD. The instructions of how to get the build environment set up are probably more valuable than the actual source code, but eh, here it is anyway. The sample image link is broken right now, or else it would show what it really looks like in action.

Hyvok
Mar 30, 2010
http://ugfx.org/ I managed to find this and it looks fairly promising for graphics!

Edit: Also heard that it is possible to make qt run standalone on some bigger ARMs which sounds like an interesting project, though I have no experience in porting anything. I wonder how much space the base qt-libraries would take though...

Hyvok fucked around with this message at 10:40 on Dec 22, 2013

Luigi Thirty
Apr 30, 2006

Emergency confection port.

I dug out my old TI Launchpad board and installed the latest version of CCS. After a little fiddling I pieced together the UART example code into something that lets me control the onboard LEDs with ASCII commands sent over a serial connection so now I can blink them externally. I wrote a little Morse code definitions C library and currently it's blinking cuss words at me :toot:

I wish I had any electronics equipment at all so I could make it do something else :saddowns:

It's an old model though (rev 1.0 Value Line with a 2231 instead of a 2553) and I got a gift card for Christmas so I ordered an Arduino and a couple shields off Sparkfun. I'm really just a hobbyist who knows C and wants to make funny computer on an LCD screen and not an electronics wizard. Though doing some looking it seems as though it's really targeted at people who don't know anything with its simplistic graphical editor and stuff. I hope I didn't spend 40 bucks on the equivalent of LOGO for embedded programming.

Luigi Thirty fucked around with this message at 10:36 on Jan 4, 2014

EpicCodeMonkey
Feb 19, 2011

Luigi Thirty posted:

Though doing some looking it seems as though it's really targeted at people who don't know anything with its simplistic graphical editor and stuff. I hope I didn't spend 40 bucks on the equivalent of LOGO for embedded programming.

There's no debugger, and the IDE is horrendous. That said, it's quick for prototyping.

The upside is that the Arduino editor is just AVR-GCC behind the scenes, so as you get comfortable you can gradually swap out some of the "magic" library code for your own C/C++ code. Eventually you can throw away the IDE altogether and write in bare C/C++ and program the board through the bootloader.

By the end of it you will have a known-working hardware board (which is a very good thing, believe me) which you can re-purpose with whatever code you can cook up with, without having to use the Arduino IDE or libraries at all.

Luigi Thirty
Apr 30, 2006

Emergency confection port.

Okay, the Uno board arrived along with the 2x16 LCD shield I ordered. The board itself seems to work fine so that's good.

The problem is the connectors don't seem to do a very good job of connecting the Arduino to the shield though. It wobbles like crazy and you have to sit it just right to get the thing to even light up. It says on the wiki page that the LCD shield doesn't work on USB power so I've got a 12 VDC 800mA wall transformer plugged into the board. The board lights up when it's on wall power so I know that works. It's the latest board so there's no power input jumper. The LCD doesn't do anything with the example code they provide. It just sits there with one row of rectangles and one empty row which it says is what happens when it's not getting enough power. There were no instructions on hooking the shield up properly so I'm probably doing something wrong. The specifications say the LCD board draws 65mA peak and I don't think the Arduino draws 700mA.

e: Wait do I have to solder them to the board or something? Ugh, I don't know how to do that.

Luigi Thirty fucked around with this message at 21:02 on Jan 4, 2014

evensevenone
May 12, 2001
Glass is a solid.
You can totally skip the arduino editor and libraries and just write bare metal code. You basically have a working board with a USB port, a bootloader, and tons of peripherals, it's not that bad a deal.

If you're in windows you can even use Atmel Studio, which uses VS, and set it up to use the arduino flash tool.

The chip manufacturers have cheaper dev boards because they sell them below cost, but there's less community support.

some kinda jackal
Feb 25, 2003

 
 

Luigi Thirty posted:

e: Wait do I have to solder them to the board or something? Ugh, I don't know how to do that.

Welp, never a better time to learn than now :)

evensevenone
May 12, 2001
Glass is a solid.

Luigi Thirty posted:


e: Wait do I have to solder them to the board or something? Ugh, I don't know how to do that.

Probably not.

Can you give a link to the LCD board? There's a bunch of them.

JawnV6
Jul 4, 2004

So hot ...

evensevenone posted:

You can totally skip the arduino editor and libraries and just write bare metal code. You basically have a working board with a USB port, a bootloader, and tons of peripherals, it's not that bad a deal.

:confused: I really doubt his choice of IDE is affecting the electrical connectivity all that much?

Most shields I've dealt with are just pins that slide in. The easiest check would be to get a meter and ensure each pin is making contact. Beyond that, check the voltage your wall wart is delivering, check the +5 and +3.3 on the Uno without the shield, then check voltages on the shield itself.

Tiger.Bomb
Jan 22, 2012

Luigi Thirty posted:

I dug out my old TI Launchpad board and installed the latest version of CCS. After a little fiddling I pieced together the UART example code into something that lets me control the onboard LEDs with ASCII commands sent over a serial connection so now I can blink them externally. I wrote a little Morse code definitions C library and currently it's blinking cuss words at me :toot:

I wish I had any electronics equipment at all so I could make it do something else :saddowns:

It's an old model though (rev 1.0 Value Line with a 2231 instead of a 2553) and I got a gift card for Christmas so I ordered an Arduino and a couple shields off Sparkfun. I'm really just a hobbyist who knows C and wants to make funny computer on an LCD screen and not an electronics wizard. Though doing some looking it seems as though it's really targeted at people who don't know anything with its simplistic graphical editor and stuff. I hope I didn't spend 40 bucks on the equivalent of LOGO for embedded programming.

I couldn't even get the serial thing to work. What a piece of crap.

Luigi Thirty
Apr 30, 2006

Emergency confection port.

evensevenone posted:

Probably not.

Can you give a link to the LCD board? There's a bunch of them.

It's this one. http://linksprite.com/wiki/index.php5?title=16_X_2_LCD_Keypad_Shield_for_Arduino

JawnV6 posted:

:confused: I really doubt his choice of IDE is affecting the electrical connectivity all that much?

Most shields I've dealt with are just pins that slide in. The easiest check would be to get a meter and ensure each pin is making contact. Beyond that, check the voltage your wall wart is delivering, check the +5 and +3.3 on the Uno without the shield, then check voltages on the shield itself.

The pins are definitely not making contact. It came with little plastic header things in the bag that I'm going to assume you're supposed to solder to the corresponding holes on the shield's board.

I've just bypassed the Arduino IDE and gone straight to Atmel Studio since I love Visual Studio. Successfully "ported" over my Morse code blinker and everything. I can't stand Eclipse, TI or no TI. I do miss the debugger (oh boy sprintf statements sent over the serial connection) but not the constant freezes and crashes.

Luigi Thirty fucked around with this message at 01:44 on Jan 5, 2014

EpicCodeMonkey
Feb 19, 2011

Luigi Thirty posted:

It came with little plastic header things in the bag that I'm going to assume you're supposed to solder to the corresponding holes on the shield's board.

Hrm, that would mean you definitely need to solder them. Time to buy a cheap iron and some solder wire.

Luigi Thirty posted:

I've just bypassed the Arduino IDE and gone straight to Atmel Studio since I love Visual Studio.

I've been making a few free extensions for it that might help you:

http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=137029

evensevenone
May 12, 2001
Glass is a solid.

JawnV6 posted:

:confused: I really doubt his choice of IDE is affecting the electrical connectivity all that much?
Haha. I was replying to the earlier "this IDE sucks/did I waste my money" comment.

Luigi Thirty
Apr 30, 2006

Emergency confection port.

Yeah I downloaded the drivers and IDE package but I haven't even looked at it. I set Atmel Studio up to use the Arduino flash program, downloaded the datasheet, and I've just been plinking away at it. I felt like a genius when I got the UART configured and an interrupt handler set up to reflect incoming serial data :v:

And then I spent like an hour and a half writing a status monitor for my LED sequencer that takes commands over that serial connection. And all I've got to play with until I get the soldering crap set up is one LED :sun:

e: I got it soldered no problem. I downloaded the datasheet and an instructional article out of an old electronics magazine and I was able to make it say cuss words within a couple of hours. :toot:

Luigi Thirty fucked around with this message at 09:59 on Jan 6, 2014

JawnV6
Jul 4, 2004

So hot ...
I'm working with the MSP430 and can't use the TouchPro GUI for Stupid Reasons.

I loaded the firmware on the chip, tried to stream it through FTDI, but the tool's hardcoded to look for "MSP430..." COM ports that the launchpad provides. I'm not using the launchpad except to program the chip, I was unable to get the UART out through it, suspect it's the level shifting. This seems like an asinine problem to be having.

edit again: yeah, the COM port isn't showing anything. I've installed CCS which should've handled the vcp driver, but nothing's coming out of it with any terminals i have around

JawnV6 fucked around with this message at 00:11 on Jan 17, 2014

yippee cahier
Mar 28, 2005

modem control lines?

ImDifferent
Sep 20, 2001
Little microcontroller-based CTF hacking competition:

http://www.matasano.com/matasano-square-microcontroller-ctf/

MSP430-based, no less.

ImDifferent fucked around with this message at 09:30 on Jan 17, 2014

Tiger.Bomb
Jan 22, 2012

JawnV6 posted:

I'm working with the MSP430 and can't use the TouchPro GUI for Stupid Reasons.

I loaded the firmware on the chip, tried to stream it through FTDI, but the tool's hardcoded to look for "MSP430..." COM ports that the launchpad provides. I'm not using the launchpad except to program the chip, I was unable to get the UART out through it, suspect it's the level shifting. This seems like an asinine problem to be having.

edit again: yeah, the COM port isn't showing anything. I've installed CCS which should've handled the vcp driver, but nothing's coming out of it with any terminals i have around

It should be easy enough to RE the client to look for the name you want.

Hell... it shouldn't be too difficult to hack it to prompt for it.

JawnV6
Jul 4, 2004

So hot ...

Tiger.Bomb posted:

It should be easy enough to RE the client to look for the name you want.

Hell... it shouldn't be too difficult to hack it to prompt for it.

I have a release at the end of next week so between doing legit work I know will ship out and faffing about with RE a .jar it's a pretty easy choice. Worst case we have a FAE visiting early next week who can hopefully do without the tool. I went through all the basic configurations (SM/A clk, 64/512/8192/32768) and none of them showed a great response. I sorta suspect the hardware, but it works decently enough from a stable voltage and clocked off the VLO.

Not sure why TI's vcp wouldn't work. I reinstalled drivers, tried multiple launchpads, nothing. Eh, plenty of other concerns to mess with.

nmfree
Aug 15, 2001

The Greater Goon: Breaking Hearts and Chains since 2006
(My apologies if this has been asked and answered already in this thread.)

I got an Arduino Nano (specifically the SainSmart version) yesterday, and initially it worked great while playing with some of the sample programs. I then breadboarded a simple regulated external power supply with an LM317 that I had sitting around. I hooked the Nano up to that and for a while everything worked just fine- it would still connect over just the USB cable for programming and running programs, and it would accept programming and run while running on external power. Now, however, when I plug it into USB it doesn't power up at all (if I repeatedly plug it in and unplug it once in a while the TX light will come on briefly but then the whole thing acts dead). If I hook the Nano up to external power, the loaded software runs, but if I plug the USB cable in Windows gives me an error about an "Unrecognized USB Device". I've tried several different cables (all of which worked before) on a couple of different USB ports (which also worked), so I doubt that's the problem. I also assume the Nano itself is still fine, since it starts right up and runs the LED flashing/fading program that I loaded onto it when on external power.

According to the internet, a pin on the FTDI chip that should be grounded is left floating on the Nano design. I checked with a multimeter, and the TEST pin on mine is indeed floating instead of being grounded. Is the internet correct that if I solder the TEST pin to the ground pin next to it my problem will be fixed? Is that even A Thing? Has anyone run into this before? Is my board totally fried and beyond help? :ohdear:

FSMC
Apr 27, 2003
I love to live this lie

ImDifferent posted:

Little microcontroller-based CTF hacking competition:

http://www.matasano.com/matasano-square-microcontroller-ctf/

MSP430-based, no less.

I haven't really done anything with assembly before but this is quite fun.

Adbot
ADBOT LOVES YOU

My Rhythmic Crotch
Jan 13, 2011

nmfree, consult the datasheet for the FTDI chip in question. What does the test pin do? Then look at the schematic for whatever arduino you bought. Does it seem reasonable that the circuit in question could be acting the way it is now that you know what the test pin does? Once you've gotten that far, you should know if it's safe or not to try grounding the test pin and see if it rescues your arduino.

  • Locked thread