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
Harik
Sep 9, 2001

From the hard streets of Moscow
First dog to touch the stars


Plaster Town Cop

hobbesmaster posted:

at that point can't you get m4s that'll be more powerful?

For $5 with 32MB DDR included and drives LCDs natively? I'm all ears.

I think it's $3-$4 for us, I'm just going by avnet pricing on it. I see a lot of M4s for that price, but none that include the RAM. It's insane how cheap these parts are. Good news though, there's slightly more recent part running 3.10.x so I don't have to gently caress around with pre-device-tree initialization.

For smaller projects, the $1-$2 M4s are great.

Adbot
ADBOT LOVES YOU

big shtick energy
May 27, 2004


I guess even a cheap external sdram with an m4 would blow the bom?

gonadic io
Feb 16, 2011

>>=

gonadic io posted:

is there a reason to buy an arduino zero over a MKRZero? The micro touts that is has the same pins, and it's about half the price. Is it just a more modern (smaller) upgrade?

Also it runs arm so it's fairly easy to get rust to compile on!

I bought a CO2 tank, a regulator, some solenoid valves, and a gyroscope chip. Here's hoping that I actually do something with it

suffix
Jul 27, 2013

Wheeee!

gonadic io posted:

Also it runs arm so it's fairly easy to get rust to compile on!

I bought a CO2 tank, a regulator, some solenoid valves, and a gyroscope chip. Here's hoping that I actually do something with it

i tested compiling and running rust on the m0-based microbit based on https://github.com/SimonSapin/rust-on-bbc-microbit,
but then i realized i didn't have time to reimplement everything i needed from scratch so i just used python

hobbesmaster
Jan 28, 2008

Harik posted:

For $5 with 32MB DDR included and drives LCDs natively? I'm all ears.

I think it's $3-$4 for us, I'm just going by avnet pricing on it. I see a lot of M4s for that price, but none that include the RAM. It's insane how cheap these parts are. Good news though, there's slightly more recent part running 3.10.x so I don't have to gently caress around with pre-device-tree initialization.

For smaller projects, the $1-$2 M4s are great.

i didn't realize it was a mcm with the ram onboard. that's kinda nifty, if it wasn't 2017. now I almost feel bad for bitching about a at91sam9x earlier. I assume you're not expecting to run JavaScript at least

gonadic io
Feb 16, 2011

>>=
I have a little gyroscope chip that I'd like to connect to a small pcb so I can mount it in the desired orientation. It doesn't have pins though, it looks like this:

It's roughly 1cm a side.

What's the usual way to connect one of these? I saw one person mount it upside down on the board, and solder wires to each of the pads. This is pretty fiddly though, is this the usual way to do it?

The device is 5V and draws 51mA. Is a 0.01microF bypass okay? I plan to put it on the board itself as I'll never not want it.

Sorry for the stupid questions but I am very new to the wonderful world of hardware.

BobHoward
Feb 13, 2012

The only thing white people deserve is a bullet to their empty skull
the "true" way to do it is have a pcb with the proper land pattern, get some solder paste onto the pcb's lands, place the part (and also paste/place for all the other surface mount parts), heat the whole thing in an oven or use a hot air gun to reflow the solder

if you do reflow right (the right amount of solder paste, the right geometry of the land pads, etc) the surface tension of the molten solder auto-aligns the parts so placement doesn't even have to be super accurate

you may be able to find prototyping pcbs that break out the pins from a package like that to something easier to deal with. you'd still have to hand solder the part to that board, but you'd avoid needing to make a custom pcb just for a one-off. look up the name of the package in the gyro's data sheet and google that plus "prototyping board" or "breakout board" or whatever. might also be able to do a more targeted search on digikey's website (digikey is the poo poo for buying small quantities of stuff for proto)

JawnV6
Jul 4, 2004

So hot ...

BobHoward posted:

look up the name of the package in the gyro's data sheet and google that plus "prototyping board" or "breakout board" or whatever. might also be able to do a more targeted search on digikey's website (digikey is the poo poo for buying small quantities of stuff for proto)

yeah, the great thing about arduino and other intro-grade hardware kits is that they handle 99% of the digital abstraction for you. all the power delivery/bypass caps in place, all of the crystals properly shielded, etc. you write Wiring code, it toggles pins. fwiw, this was absolutely not the case in 2007

the downsides are cost and size. the breakout boards will be larger than you need and cost more than bare chips in bulk. also, arguably, the lengths that Wiring goes to maintain the abstraction go to far (e.g. calling PWM "analog") but that's not at issue for gonadic

i've never personally soldered a component that small :shobon:

hobbesmaster
Jan 28, 2008

you can of course use arduino shields with other MCUs that don't have a dev environment with that amount of abstraction. just match the pin out and you're good to go with a giant ecosystem of breakout boards for prototyping.

one example is STM's nucleo line for their ARM parts http://www.st.com/en/evaluation-tools/stm32-mcu-nucleo.html

ps: be careful with digikey and dev boards. they sell my company's dev kits for close to 50% above MSRP, so double check the pricing on the kits. (the "production" hardware is the correct price of course)

hobbesmaster fucked around with this message at 19:41 on Jan 6, 2017

Bloody
Mar 3, 2013

gonadic io posted:

I have a little gyroscope chip that I'd like to connect to a small pcb so I can mount it in the desired orientation. It doesn't have pins though, it looks like this:

It's roughly 1cm a side.

What's the usual way to connect one of these? I saw one person mount it upside down on the board, and solder wires to each of the pads. This is pretty fiddly though, is this the usual way to do it?

The device is 5V and draws 51mA. Is a 0.01microF bypass okay? I plan to put it on the board itself as I'll never not want it.

Sorry for the stupid questions but I am very new to the wonderful world of hardware.

when i am doing hand assembly of QFN (quad flat no-leads) packages, i aim to:
* when i design the board, expand the pads on the board for the part a bit so they extend comfortably past the part. this gives you a spot to heat up when the part is placed
* dump a bunch of flux on the landing site
* tin the pads on the board as evenly as possible
* plop the part down, plausibly with more flux
* heat up the pad fingers on the board until they flow with the part
* inspect under a microscope a bunch
* retouch and remove solder where needed
* do a lovely job cleaning it

its better/easier to do it with solder paste, and you can even hand-dispense it without a stencil. proper stenciled solder paste and reflow is the best way to go but kinda overkill for a one-off thing for yourself. if you can get some paste on every pad and plop down the part, going around it with an iron will probably be sufficient to get a good flow

Bloody
Mar 3, 2013

in terms of decoupling caps, the first thing i would do is check the datasheet for a typical application circuit or reference schematic of some form, which should include guidelines for decoupling the part. at 51 mA, .01 uF sounds insufficient to my intuition

longview
Dec 25, 2006

heh.
i usually just pop in a 1-10µF 0603 ceramic unless the data sheet is very specific about what is needed

Poopernickel
Oct 28, 2005

electricity bad
Fun Shoe
decoupling is actually a super-complicated topic - more uFs (uF uF uF) aren't always better

remember: it's not the size of the capacitor, it's how you gently caress

I'd plop down a 0.1uF in the smallest package you're comfortable with, right next to each power pin. if you need ~precise~ measurements, maybe add a 1uF and an 0.01uF in parallel

gonadic io
Feb 16, 2011

>>=

Poopernickel posted:

decoupling is actually a super-complicated topic - more uFs (uF uF uF) aren't always better

remember: it's not the size of the capacitor, it's how you gently caress

I'd plop down a 0.1uF in the smallest package you're comfortable with, right next to each power pin. if you need ~precise~ measurements, maybe add a 1uF and an 0.01uF in parallel

i do need as ~precise~ as possible, since in theory this is one day supposed to be a rocket guidance system: https://github.com/djmcgill/to-the-moon

i will check the data sheet though.

the chip arrived today!! but my anti-static wriststrap hasn't though so i can't open the bag. i really am starting from nothing here.

hobbesmaster
Jan 28, 2008

lol an anti static strap, look at this noob

spankmeister
Jun 15, 2008






gonadic io posted:

I have a little gyroscope chip that I'd like to connect to a small pcb so I can mount it in the desired orientation. It doesn't have pins though, it looks like this:

It's roughly 1cm a side.

What's the usual way to connect one of these? I saw one person mount it upside down on the board, and solder wires to each of the pads. This is pretty fiddly though, is this the usual way to do it?

The device is 5V and draws 51mA. Is a 0.01microF bypass okay? I plan to put it on the board itself as I'll never not want it.

Sorry for the stupid questions but I am very new to the wonderful world of hardware.

The dead bug style (upside down with flying leads soldered to the chip) is okay for prototyping. QFP can still be hand soldered in the proper orientation though, unlike BGA or w/e.

Bloody
Mar 3, 2013

ESD is a myth

gonadic io
Feb 16, 2011

>>=

hobbesmaster posted:

lol an anti static strap, look at this noob


Bloody posted:

ESD is a myth

brb putting on my woollen jumper, playing with my cats and some balloons, moonwalking across my carpet and then working with this £50 chip

Captain Foo
May 11, 2004

we vibin'
we slidin'
we breathin'
we dyin'

gonadic io posted:

brb putting on my woollen jumper, playing with my cats and some balloons, moonwalking across my carpet and then working with this £50 chip

video pls

hobbesmaster
Jan 28, 2008

gonadic io posted:

brb putting on my woollen jumper, playing with my cats and some balloons, moonwalking across my carpet and then working with this £50 chip

just touch a piece of metal after you sit down

longview
Dec 25, 2006

heh.

Poopernickel posted:

decoupling is actually a super-complicated topic - more uFs (uF uF uF) aren't always better

remember: it's not the size of the capacitor, it's how you gently caress

I'd plop down a 0.1uF in the smallest package you're comfortable with, right next to each power pin. if you need ~precise~ measurements, maybe add a 1uF and an 0.01uF in parallel

it is complicated when you're driving high speed FPGAs that don't have internal decoupling or you have a ton of high speed unbalanced digital I/O to consider

of course for those caps to have any effect you'd need a power+ground plane on the board to match, and if you're dead bugging an IC on a prototyping board the wires between the board and IC will add so much inductance that the sick gains from using a beautifully calculated broad band 0402 or 0201 packaged decoupling network with power plane capacitance will be completely irrelevant

and there's two sides of the same issue here; one aspect is making sure there's a PDN with a low enough impedance at all frequencies the devices under load needs to operate and drive I/O without di/dt related voltage drops, the other is making sure the incoming power supply doesn't have a bunch of switching noise from other devices on the same rail

for a gyroscope the output is probably analog or some slow interface like I2C/SPI and it might make more sense to put a dedicated linear regulator + some series resistance/inductance near it, along with whatever decoupling the device + regulator needs

Sapozhnik
Jan 2, 2005

Nap Ghost
i got a risc-v microcontroller board in an arduino form factor today

maybe i'll even find some time to do something cool w/ it

gonadic io
Feb 16, 2011

>>=
my zero should be arriving today! i already wrote some (rust) code for it, based off the great hannobraun.de/embedded/

that's for a duo though, so none of the memory addresses are the same (which I looked up from the data sheet). hopefully it'll work.

JawnV6
Jul 4, 2004

So hot ...
good luck!

just curious, how nicely does rust play with gdb/lldb?

gonadic io
Feb 16, 2011

>>=

JawnV6 posted:

good luck!

just curious, how nicely does rust play with gdb/lldb?

seems fine, i've not tried it: https://michaelwoerister.github.io/2015/03/27/rust-xxdb.html

hobbesmaster
Jan 28, 2008


wheres he talk about gdb? openocd+gdb is finicky with supported languages, I couldn't imagine it with unsupported ones.

edit: actually rust is supported by gdb now so it may not be as bad as I thought

hobbesmaster fucked around with this message at 23:33 on Jan 9, 2017

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?

JawnV6 posted:

good luck!

just curious, how nicely does rust play with gdb/lldb?

rust uses LLVM for the backend, right? so LLDB should be along for the ride in a pretty straightforward fashion

especially since all of the changes to enable Swift support are really more about changes to enable support for languages that aren't subsets of Objective-C++

hobbesmaster
Jan 28, 2008

i thought lldb couldn't handle embedded targets?

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?

hobbesmaster posted:

i thought lldb couldn't handle embedded targets?

depends on the embedded target

it can speak the gdb remote serial protocol and if it has support for your architecture/ABI/object/debug format (e.g. ARM, ARM ABI, ELF, DWARF) you can do an awful lot with it

and you can add any missing bits in a pretty straightforward fashion, the system is pretty modular, it's just if you need to add an entirely new architecture that things get hairy because you basically have to add that to LLVM

(so no 68K LLDB support yet, alas)

Jimmy Carter
Nov 3, 2005

THIS MOTHERDUCKER
FLIES IN STYLE

eschaton posted:

depends on the embedded target

it can speak the gdb remote serial protocol and if it has support for your architecture/ABI/object/debug format (e.g. ARM, ARM ABI, ELF, DWARF) you can do an awful lot with it

yo out of curiosity how required would something like https://github.com/blacksphere/blackmagic/wiki

is this just adding an interface that you can already get elsewhere a different hardware option, or is it literally something that you couldn't do without it if you were trying to do remote debugging?

gonadic io
Feb 16, 2011

>>=
im going insane here trying to get rust onto my arduino zero.

this c program, when uploaded via the arduino IDE, turns the led on:

code:
void setup() {
  *(unsigned long *)0x41004408 = 131072ul;   // Set the direction of the port pin PA17 to an output
  *(unsigned long *)0x41004418 = 131072ul;   // Switch the output to 1 or HIGH
}
i wrote the same rust code, which produces the following binary:
code:
$ arm-none-eabi-readelf -h target/arduino-zero/debug/zero
ELF Header:
  Magic:   7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00 
  Class:                             ELF32
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           ARM
  Version:                           0x1
  Entry point address:               0x2001
  Start of program headers:          52 (bytes into file)
  Start of section headers:          12528 (bytes into file)
  Flags:                             0x5000200, Version5 EABI, soft-float ABI
  Size of this header:               52 (bytes)
  Size of program headers:           32 (bytes)
  Number of program headers:         3
  Size of section headers:           40 (bytes)
  Number of section headers:         18
  Section header string table index: 17
code:
$ arm-none-eabi-objdump -Cd target/arduino-zero/debug/zero

target/arduino-zero/debug/zero:     file format elf32-littlearm


Disassembly of section .text:

00002000 <Reset_Handler>:
    2000:	b081      	sub	sp, #4
    2002:	e7ff      	b.n	2004 <Reset_Handler+0x4>
    2004:	e7ff      	b.n	2006 <Reset_Handler+0x6>
    2006:	f244 4008 	movw	r0, #17416	; 0x4408
    200a:	f2c4 1000 	movt	r0, #16640	; 0x4100
    200e:	f44f 3100 	mov.w	r1, #131072	; 0x20000
    2012:	6001      	str	r1, [r0, #0]
    2014:	e7ff      	b.n	2016 <Reset_Handler+0x16>
    2016:	f244 4018 	movw	r0, #17432	; 0x4418
    201a:	f2c4 1000 	movt	r0, #16640	; 0x4100
    201e:	f44f 3100 	mov.w	r1, #131072	; 0x20000
    2022:	6001      	str	r1, [r0, #0]
    2024:	e7ff      	b.n	2026 <Reset_Handler+0x26>
    2026:	e7fe      	b.n	2026 <Reset_Handler+0x26>
this does, as far as I can see, nothing. i was hoping to get some working code before having to deal with the debugger :/

i can't really read assembly, but from what I gather
movw r0, #17416 ; 0x4408
movt r0, #16640 ; 0x4100
mov.w r1, #131072 ; 0x20000
str r1, [r0, #0]
really should be doing what I want for the first instruction?? so what's going wrong??

e: also i'm uploading them the same way using the bossac bundled with the arduino IDE

gonadic io fucked around with this message at 23:22 on Jan 14, 2017

hobbesmaster
Jan 28, 2008

well does the c bin look any different? does the base address match on the c bin and the rust one?

edit: bins don't have addresses, is there a hex or something?

hobbesmaster fucked around with this message at 23:31 on Jan 14, 2017

gonadic io
Feb 16, 2011

>>=
now that i think about it, it's only the c version the IDE uploads that works not my self-compiled c version.

i checked the logs though, and the arduino one does "arm-none-eabi-objcopy" -O binary "[...]/Blink2.ino.elf" "[...]Blink2.ino.bin"" too.

i'm trying to inspect the .ino.bin file that gets uploaded though (the IDE one that works), and readelf and objcopy both choke completely with
"readelf: Error: Not an ELF file - it has the wrong magic bytes at the start" and "File format not recognized"

which is weird. but i looked and the ide compiles with
arm-none-eabi-g++ -mcpu=cortex-m0plus -mthumb
which im doing so i have no loving clue what's going on

Sapozhnik
Jan 2, 2005

Nap Ghost
A few things to check

- Is the vector table getting emitted at 0x00000000? The NVIC will read the first word of that table to determine where to jump. I'm guessing this chip is a Cortex-M, which means it only supports Thumb instructions, which in turn means that the jump address needs to have its lsbit set to 1 to indicate Thumb mode. If your vector table is just zeros then it'll get stuck in an infinite exception loop because it'll try to jump to 0 in non-Thumb mode to start execution. Which would almost work, seeing 0 is a NOP on ARM (i think) which would unintentionally NOP-sled you all the way to Reset_Handler, except for the fact that your instructions are Thumb instructions and also Cortex-M chips are only capable of decoding Thumb instructions anyway, so any attempt to execute non-Thumb instructions is an error.

Try

$ objcopy yourprogram.elf -O binary yourprogram.bin
$ hexdump -C yourprogram.bin

and see if there's a vector table at the beginning.

- Some micros (well, EFM32 does, idk about any others) need you to open a clock gate to the GPIO unit before it will respond to register accesses. Check your micro's reference manual to see if this is the case.

gonadic io
Feb 16, 2011

>>=
i think that i'm just missing system init maybe? that still doesn't explain why the "official" bin file won't open in objdump or readelf

Spatial
Nov 15, 2007

that asm is correct but not enough by itself to execute a program. is there a vector table section? you need it to reach the program entrypoint. if you don't the mcu will just enter a lockup state and halt.

the vector table is address 0. first word is the initial stack pointer, second is the reset entrypoint.

edit: actually that code is ARMv7-M but the M0+ only supports ARMv6-M. that asm will hardfault

Spatial fucked around with this message at 00:10 on Jan 15, 2017

Sapozhnik
Jan 2, 2005

Nap Ghost

gonadic io posted:

i think that i'm just missing system init maybe? that still doesn't explain why the "official" bin file won't open in objdump or readelf

a BIN file is a raw image of the contents of a chip, stripped of all its metadata.

an ELF file is a metadata-rich structured data file which can be converted into a BIN file but not vice versa. edit: It's the same sort of thing as a Windows EXE.

Sapozhnik
Jan 2, 2005

Nap Ghost
gonna be honest with you here this is really basic stuff that you need to understand before you start programming microcontrollers

playing around with Rust will just complicate matters, stick to C until you get a better handle on what's going on. Happy to answer any further questions though.

Spatial
Nov 15, 2007

compiling for the right platform is also a good start :v:

Adbot
ADBOT LOVES YOU

Sapozhnik
Jan 2, 2005

Nap Ghost
well no afaict the platform is right but there is no vector table. How to emit that depends on the toolchain being used and what its linker script looks like.

  • Locked thread