Skip to main content

Messages

This section allows you to view all Messages made by this member. Note that you can only see Messages made in areas you currently have access to.

Messages - Arkku

1
Bus Pirate Support / Re: BusPirate v3 - burnt MOSI line
[quote author="ian"]As far as I know, MPLAB 8 is still the only official compiler. MPLABX is not recommended for use in production. This could have changed, but arhi had some strong words about the situation a few weeks ago I think.

I also think there are several level of optimization in the compilers under 8. We don't use them because they break the firmware, but only the highest level is disabled after the initial 60 days.[/quote]

Why does the optimization break firmware? Is it a problem in how the firmware is coded, or is the compiler itself so badly broken? I haven't noticed any problems running the firmware compiled with MPLAB X and [tt:]-Os[/tt:], so if it's specific to the MPLAB 8 compiler then that would seem yet another reason to switch…
2
Bus Pirate Development / Re: Re: Compiling Bus Pirate firmware with MPLABX (under lin
[quote author="beeduino"]I used this info to recompile the firmware but whatever value for Program Memory End I set  - the hex file was the same - no diffs. What other options could be in affect?[/quote]

Well, the only thing I can think of is that this change did not take effect, e.g., you only tried to “Export hex” and did not “Clean and build”, or maybe the setting did not get saved for some reason. (Did you click “Apply”?)

Unfortunately the MPLAB user interface is so bad that I cannot even guess what other settings I might have touched that could possibly affect this. If the above suggestions don't work, I would perhaps try re-importing the MPLAB 8 project and redoing the configuration without ever compiling with the incorrect settings.

[quote author="beeduino"]
MPLABX 1.0 under debian, optimization is set to -O1, Bus Pirate svn code.[/quote]

I'm using the same configuration, except I use [tt:]-Os[/tt:] optimization.
3
Bus Pirate Support / Re: BusPirate v3 - burnt MOSI line
[quote author="ian"]I'm sorry, I don't use MPLABX yet, I can't help with the export.[/quote]

I think maybe you should; it's quite a sad state of affairs that the MPLAB X project in SVN won't even compile (one has to import the MPLAB 8 project), and the deprecated MPLAB 8 is not only one of the worst IDEs I have ever come across, but also Windows only and does not include a free optimizing compiler.
4
Bus Pirate Support / Re: BusPirate v3 - burnt MOSI line
[quote author="beeduino"]
I was trying to recompile the firmware yesterday with all available settings - 0xa7fa, 0xa6ff, 0xa7ff.
In all the cases the hex file was the same - no diff.[/quote]

Did you do “Clean and build” after changing the setting? It has no effect if you just “Export hex”. I had the exact same problem with the same error message, but solved by following the steps I gave in the MPLAB X thread.
5
Bus Pirate Support / Re: BusPirate v3 - burnt MOSI line
[quote author="beeduino"]
Also I compiled firmware but when making exporting for bootloader in MPLABX the setting of    0xa7fa was prefixed with "!!!".
And it looked like a warning.[/quote]

Change the 0xa7fa to 0xa6ff to get rid of the warning.

(I struggled with this same issue earlier. I am now using MPLAB X to compile the firmware with no issues.)
6
Bus Pirate Development / Re: Patch to add hardware PWM support down to 2Hz
Note: there was a problem in the previous patch when using BASIC scripting to do frequencies over 32KHz: the last line of [tt:]updatePWM[/tt:] in [tt:]AUXpin.c[/tt:],

[tt:]PWMstart(PWMfreq * 1000, PWMduty);[/tt:]

needs to be

[tt:]PWMstart((long)PWMfreq * 1000, PWMduty);[/tt:]

or the value will overflow. I've updated the patch posted above, but the two downloaders of the previous version should change this line.

On another note, BASIC scripting command [tt:]freq[/tt:] seem actually quite silly now that it takes KHz only. I did not add a Hz equivalent, though, since again there is the problem of [tt:]int[/tt:] having insufficient range to represent the full PWM range in Hz,  and there's no [tt:]long[/tt:] equivalent of [tt:]getint[/tt:] (which would be trivial to make but would increase code size again).

I'm also not sure how you would prefer to deal with the KHz vs Hz in BASIC? As BASIC hasn't been available on <v4 by default(?), I don't think it would be particularly problematic to break compatibility with existing BASIC scripts and just use Hz, and also on the v4 the size issue of creating a [tt:]long[/tt:] version should not be, well, an issue. (But, for what it's worth, I only have v3.5 myself and the BASIC scripting still fits, even with this patch.)
7
Bus Pirate Development / Re: Patch to add hardware PWM support down to 2Hz
[quote author="ian"]Thank you for the patch. Do you think we could combine it into a single command by adding a 'f' submenu that prompts for Hz range or KHz range?[/quote]

How would that "f" command work, do you mean that it would have three questions (Hz/KHz, frequency, duty cycle)? If yes, then it would be better, in my opinion, to just always ask the frequency in Hz; it's easier to just type "000" after the KHz than read and answer another prompt. Or if you mean that it should toggle the behaviour of the "g" command between Hz and KHz, then that has the problem of introducing a hidden state into the system + if there is an additional menu for this functionality why not just the simpler (and smaller code) of the current "g"/"G"…

Personally I think there are only two reasons to have the KHz version at all:

1) Compatibility with existing scripts that may rely on "g" to take KHz arguments.
2) There is no [tt:]long[/tt:] equivalent of [tt:]getint[/tt:] so "G" cannot take command-line frequencies over 32,767Hz (but can in the interactive menu due to [tt:]getlong[/tt:]).

[quote author="ian"]
Adding this much code in the BPv3 firmware could be problematic because we are running out of room, but this should go in v4 for sure.
[/quote]

Yes, the original patch adds 1161 bytes of code to BPv3 when compiled in MPLAB 8 (no optimizations). I tried to tweak it for smaller code size and got it down to 867 bytes (and also changed [tt:]updatePWM[/tt:] to use the same PWM setup routine instead of duplicating all the code). With MPLAB X none of this is particularly relevant, since with [tt:]-Os[/tt:] (size optimization) enabled the build is over 14K smaller. (I would argue for transitioning to MPLAB X [tt:]-Os[/tt:] builds regardless of this patch, but that is another topic. =)


In any case, the new patch (smaller compiled code) is attached (and also uploaded to the URL in the first post). (This patch is to be applied instead of, not on top of, the original patch I posted above. Use [tt:]svn revert AUXpin.* procMenu.*[/tt:] to undo the first patch if already applied.)
8
Bus Pirate Support / Re: Bus Pirate frequency generator Hz range
The inability of to set hardware PWM lower than 1KHz is due to the Bus Pirate firmware, not the chip itself. It is possible to set hardware PWM down to 2 Hz by using the binary mode commands to directly manipulate the registers. I made a little firmware patch for the Bus Pirate to enable this in the interactive ASCII mode as well, see this thread.
10
Bus Pirate Development / Patch to add hardware PWM support down to 2Hz
Hi, while writing a binary mode library for the Bus Pirate I noticed that it's possible to set the hardware PWM down to 2 Hz, but the interactive ASCII interface (command [tt:]g[/tt:]) only provides options down to 1 KHz. I made a small patch to the firmware, which adds a new command [tt:]G[/tt:] that asks for the PWM frequency in Hz. Using an external frequency counter I found this working down to 2 Hz on my BPv3.5, although I'm not sure if it's a limitation of my frequency counter or of the chip that 1 Hz doesn't work (so 1 Hz value is allowed).

Some observations:

1) I needed to enable [tt:]getlong[/tt:] for BPv3, previously it was only used with BPv4.

2) Confusingly [tt:]getlong[/tt:] is actually the equivalent of [tt:]getnumber[/tt:] and not [tt:]getint[/tt:] as one might think, and there is no [tt:]long[/tt:] version of [tt:]getint[/tt:]. As such it is not possible to specify a command-line argument to "G" with a frequency higher than [tt:]INT_MAX[/tt:]. I don't see this as a major problem, though, since one can use the "g" version in KHz with higher frequencies (that wouldn't have 1 Hz precision anyhow).

3) I also changed the [tt:]g[/tt:] command (PWM in KHz) to use my modified method for calculating the register values. This saves code space so the size impact of adding this command is fairly minimal (essentially just [tt:]getlong[/tt:]). However, this means that any bugs in my patch will also affect the old "g" command. I did test this with various options, though, and my calculation method is simpler with fewer magic numbers.

(There is still an internally used [tt:]updatePWM[/tt:] that I didn't touch. Personally I think the cleanest solution would be to have that use the same PWM calculation methods as well instead of duplicating everything for the interactive and non-interactive versions as seems to be done throughout the codebase.)

4) I don't know where the thresholds used for prescaler selection come from, but I kept the existing values (4 KHz, 31 KHz, and 245 KHz).

The patch is against the latest SVN sources, and can be applied in the firmware sources directory ([tt:]trunk/Firmware[/tt:]) with [tt:]patch -p0 <my_patch.diff[/tt:].


Oh, the patch itself:
http://arkku.com/misc/buspirate_hz_pwm_patch.diff
11
Bus Pirate Support / Re: Firmware update on Linux ?
[quote author="atmega88"]What distribution you are using ? I use Debian Squeeze and it is installed from net-install cd and i disabled apt for installing recommended and suggested packages so i maybe missing some package. But i did look and i think that i have everything for usb to work propriety...[/quote]

I have Ubuntu 10.04, current Debian stable (probably squeeze but I forget the nickname), and also Mac OS X with avrdude installed from macports. Works on all with the command line shown above. Are you sure you have all six wires connected properly to your AVR chip? They are BP MOSI -> AVR MOSI, BP MISO -> AVR MISO, BP CLK -> AVR SCK, BP CS -> AVR RESET (not SS!), BP GND -> AVR GND, BP 3.3/5V -> AVR VCC (unless you are using another power supply).
12
Bus Pirate Support / Re: Firmware update on Linux ?
I just tried my Bus Pirate with [tt:]avrdude[/tt:], it worked just fine with this command (nothing else done first to set up, just this!):

Code: [Select]
avrdude -v -b 115200 -c buspirate -p atmega168 -P /dev/bus_pirate -U flash:w:/tmp/LED.hex

As for electrical connections, only the Bus Pirate is powered in my setup, the AVR board is not (it gets power for programming from the Bus Pirate).
13
Bus Pirate Support / Re: Firmware update on Linux ?
This won't work:

Code: [Select]
stty speed 115200

It would set the speed of the current terminal (but it doesn't do anything since you are not using an actual serial terminal). You need to do:

Code: [Select]
stty 115200 </dev/ttyUSB0

(But I don't think this makes any difference if you're just using [tt:]avrdude -b 115200[/tt:].)
15
Bus Pirate Support / Re: 1-wire ROM search broken in binary mode? (Edit: No.)
I'm writing my own Ruby library for controlling the Bus Pirate in binary mode. I actually have nearly the complete binary mode (all protocols) implemented, but I want to fine-tune and test it a bit before I release it (open source). The broken part was just a few routines I copypasted from somewhere to get started (I started with 1-wire since I had the DS18B20 thermometers handy), now I've rewritten the broken part and switched to using Ruby's [tt:]serialport[/tt:] gem.

Teaser example:

Code: [Select]
bp = BusPirate.new('/dev/bus_pirate')
bp.onewire_protocol do |one|
  one.set_pins(:power => true, :pullup => true)
  devices = one.rom_search
  devices.each_with_index do |rom_id, i|
    puts "#{i + 1}. 0x#{rom_id.to_s(16)} #{one.identify_device(rom_id)}"
  end
  one.match_rom_write(devices.last, 0x44)
  sleep 0.75
  one.match_rom_write(devices.last, 0xBE)
  p one.read(9).collect { |byte| "0x#{byte.to_s(16)}" }
  ds = BusPirate::DallasTemp.new(one)
  ds.find_devices
  ds.convert_and_read.each_pair do |rom_id, data|
    puts "#{data[:device]} 0x#{rom_id.to_s(16)}: #{data[:celsius]} C"
  end
end
bp.exit_binary_mode

Outputs:

Code: [Select]
1. 0x8f959550000002a 1K memory iButton
2. 0x28286591020000eb programmable resolution digital thermometer
3. 0x28a4ce910200003f programmable resolution digital thermometer
4. 0x282b6b9102000010 programmable resolution digital thermometer
["0xaf", "0x1", "0x4b", "0x46", "0x7f", "0xff", "0x1", "0x10", "0xbc"]
ds18b20 0x28286591020000eb: 25.6875 C
ds18b20 0x28a4ce910200003f: 25.9375 C
ds18b20 0x282b6b9102000010: 27.25 C

( ! ) Fatal error: Uncaught exception 'Elk_Exception' with message 'Please try again. If you come back to this error screen, report the error to an administrator.' in /var/www/dangerousprototypes/forum/sources/database/Db-mysql.class.php on line 696
( ! ) Elk_Exception: Please try again. If you come back to this error screen, report the error to an administrator. in /var/www/dangerousprototypes/forum/sources/database/Db-mysql.class.php on line 696
Call Stack
#TimeMemoryFunctionLocation
10.02382459536session_write_close ( )...(null):0
20.02412591136ElkArte\sources\subs\SessionHandler\DatabaseHandler->write( )...(null):0
30.02412591912Database_MySQL->query( ).../DatabaseHandler.php:119
40.06902730656Database_MySQL->error( ).../Db-mysql.class.php:273