Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zolertia Z1 port for RIOT OS #893

Merged
merged 2 commits into from
May 16, 2014
Merged

Zolertia Z1 port for RIOT OS #893

merged 2 commits into from
May 16, 2014

Conversation

rousselk
Copy link
Contributor

First version of RIOT OS for Zolertia Z1 (platform described in RIOT's Wiki on GitHub).

What should work:

  • All functions related to the MSP430F2617 MCU; this includes: timers, UARTs (can communicate on the micro-USB port, and thus have a shell/console), GPIOs (can control LEDs, receive signal from user button...), etc.
  • 802.15.4 networking via the CC2420 transceiver.

Todo (in a next version):

  • support the real-world sensors (TMP102 thermometer and ADXL345 accelerometer) by creating the appropriate drivers
  • support the data/log flash memory (M25P16 -- 16 Mbit Flash chip)

@rousselk rousselk added the msp label Mar 17, 2014
@OlegHahm
Copy link
Member

How can I test this? I tried with hello_world and ipc_pingpong but failed to see any output in pyterm using the µUSB connector (flashing seems to work).

@rousselk
Copy link
Contributor Author

One can also execute the built ELF file with Cooja (after renaming 'xxx.elf' to 'xxx.z1').

But yes, there are still issues I need to address (especially with the radio transceiver).

@rousselk
Copy link
Contributor Author

Indeed, pingpong works on Cooja, but on the real machine, I can't get the expected output from the USB port (while the UART LEDs indicate that there is actually something passing on the port). Hmmm....

@rousselk
Copy link
Contributor Author

It seems to be a problem related to the MCU frequency (the UART configuration supposes it runs at 8 MHz). After a bit of fiddling with DCO configuration, I'm now having some output from the mote.

By the way, what's the pyterm you use? I'm currently using minicom to communicate with my motes, but maybe is your program better?...

@OlegHahm
Copy link
Member

Actually pyterm is a self-written python script: https://github.com/RIOT-OS/RIOT/tree/master/dist/tools/pyterm

@LudwigKnuepfer
Copy link
Member

If better means higher hackability, yes ;-)

@rousselk
Copy link
Contributor Author

Rebased on current master to have the merged #881 and #882 fixes.

@OlegHahm OlegHahm self-assigned this Mar 19, 2014
@OlegHahm
Copy link
Member

Hmm, still don't get any output from the Z1 even with UART_SLOW_MODE set to 1 and changed pyterm to 9600 baud.

@rousselk
Copy link
Contributor Author

Looks like I will have to trace this thing at the cycle-level with JTAG.
Well, stay tuned...

@OlegHahm
Copy link
Member

OlegHahm commented Apr 8, 2014

Any progress?

@OlegHahm OlegHahm added this to the Release 2014.04 milestone Apr 8, 2014
@rousselk
Copy link
Contributor Author

rousselk commented Apr 9, 2014

Well, not yet. I have to hurry and prepare some submission (as part of my thesis job) on 802.15.4 radio MAC protocols for a conference whose submission deadline is only a few days away; so I have to concentrate on that part for now, instead of watching for UART-related problem (it's also the reason I submitted some fixes about CC2420 and HW timers lately).

I don't give up on that point, rest assured it's only a matter of time before I delve into this.

@rousselk
Copy link
Contributor Author

@OlegHahm Does this change makes things better? I can now see the correct output of the 'pingpong' example.

// TACTL = 0; /* Stop Timer_A */

// BCSCTL1 &= ~(DIVA1 + DIVA0); /* remove divisor from ACLK again */

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The above 53 lines are not used at all?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are the code that configures the MSP430 clock module for the MCU frequency you choose. For now, since I'm trying to debug UART, I commented it and replaced it by direct affectation of clock HW registers...
I'll probably re-enable this portion of code when everything is fixed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you intend to fix the UART and un-comment this before the PR gets merged? If not:
It would be a lot cleaner to split it to a different PR.
If yes:
Please mark the PR as WIP (via label and description).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's an ongoing WIP effort; I just marked it as you suggested.

@rousselk rousselk added the WIP label Apr 29, 2014
@rousselk rousselk changed the title Zolertia Z1 port for RIOT OS! Zolertia Z1 port for RIOT OS (WIP) Apr 29, 2014
@rousselk rousselk changed the title Zolertia Z1 port for RIOT OS (WIP) Zolertia Z1 port for RIOT OS (experimental/WIP) Apr 29, 2014
@rousselk
Copy link
Contributor Author

Rebased on master (again).

@OlegHahm
Copy link
Member

Still cannot see any output (neither with pyterm nor with minicom). What't the intended baudrate?

@mehlis
Copy link
Contributor

mehlis commented May 2, 2014

@rousselk please look at the travis output, seems link the z1 needs some blacklisting for some boards, but every fail case needs it's attention, perhaps there is something other wrong with it :)

@OlegHahm
Copy link
Member

OlegHahm commented May 4, 2014

@rousselk please look at the travis output, seems link the z1 needs some blacklisting for some boards, but every fail case needs it's attention, perhaps there is something other wrong with it :)

I guess you meant "blacklisting for some applications".

@mehlis
Copy link
Contributor

mehlis commented May 4, 2014

blacklisting the Z1 in applications....

@rousselk
Copy link
Contributor Author

rousselk commented May 5, 2014

@OlegHahm The intended baudrate is 115200 bps as usual... Argh! What's wrong with that UART?
By the way, what kind of hardware are you using? The built-in Micro-USB port of the Z1, right?

@mehlis I'll look at this ASAP.

@OlegHahm
Copy link
Member

OlegHahm commented May 5, 2014

So

git checkout rousselk/z1-port
cd examples/ipc_pingpong
BOARD=z1 make -B clean all flash term

should result in the expected output, right? I don't see anything after:

...
make[1]: Leaving directory '/home/oleg/git/RIOT'
   text    data     bss     dec     hex filename
   8028      10    1520    9558    2556 /home/oleg/git/RIOT/examples/ipc_pingpong/bin/z1/ipc_pingpong.elf
goodfet.bsl --z1 -I -c /dev/ttyUSB3 -r -e -p /home/oleg/git/RIOT/examples/ipc_pingpong/bin/z1/ipc_pingpong.hex
MSP430 Bootstrap Loader Version: 1.39-goodfet-8
Mass Erase...
Transmit default password ...
Invoking BSL...
Transmit default password ...
Current bootstrap loader version: 2.13 (Device ID: f26f)
Changing baudrate to 38400 ...
Program ...
8038 bytes programmed.
Reset device ...
/home/oleg/git/RIOT/dist/tools/pyterm/pyterm.py /dev/ttyUSB3
Welcome to pyterm!
Type 'exit' to exit.

@rousselk
Copy link
Contributor Author

rousselk commented May 5, 2014

Indeed, it should work the way you build it...
Well, let's try something other. Is this version any better?

@OlegHahm
Copy link
Member

OlegHahm commented May 5, 2014

No difference.

@thomaseichinger
Copy link
Member

As comparison below the implementation of the OpenWSN project.
https://github.com/openwsn-berkeley/openwsn-fw/blob/develop/firmware/openos/bsp/boards/z1/uart.c#L28
They are applying other values to UCA0BR0 and UCA0BR1 although your calculations seem correct following the data sheet.

@rousselk
Copy link
Contributor Author

rousselk commented May 6, 2014

@thomaseichinger Hello. Actually the computations made by my macros produce values 0x45 for UCA0BR0 and 0x00 for UCA0BR1, like in OpenWSN code, or Zolertia's own demo code (see at http://zolertia.sourceforge.net/wiki/index.php/Mainpage:TOS_advanced#Printf_using_UART_port).

Well, I'll try to disable the macros and directly put the numeric values in the registers, but according to the JTAG debugger, it won't really change anything...

I must admit, I'm at a loss... The values I use for configuration are the same than in Contiki's Z1 port, the same that Zolertia recommend... and you have now learnt me than OpenWSN also use the same!... Just why doesn'it work now?...

@rousselk
Copy link
Contributor Author

OK, fixed the Makefiles (and reorder again the blacklisted board alphabetically), made the DCO calibration optional with #ifdef, and squashed.

After a last round of tests, I expect this one to be the one.

@thomaseichinger
Copy link
Member

👍 ACK

@thomaseichinger
Copy link
Member

I'll leave the gratification to press the merge button to you.

* This file subject to the terms and conditions of the LGPLv2. See the file
* LICENSE in the top level directory for more details.
*/

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing doxygen header

@haukepetersen
Copy link
Contributor

Ok, works fine! ACK from me once you address the documentation and comment style issues

@rousselk
Copy link
Contributor Author

Fixed doc/comments.
I squashed this directly to save some time.
Let's wait for a last Travis verdict.

@haukepetersen
Copy link
Contributor

Looking good, ACK (again)

@LudwigKnuepfer
Copy link
Member

May I suggest you reword the second commit to boards/z1: initial import?
In any case: the project's name is RIOT, not RIOT OS. (Although I guess we need to accept the fact that people will call it RIOT OS as it happens all the time...)

@rousselk
Copy link
Contributor Author

OK.

@LudwigKnuepfer
Copy link
Member

Oh, and one more thing:
Your license headers contain a copy paste error. If you use our standard license header you've got my ACK ;-)

  * This file is subject to the terms and conditions of the GNU Lesser General
  * Public License. See the file LICENSE in the top level directory for more
  * details.

@rousselk
Copy link
Contributor Author

OK (again).

@LudwigKnuepfer
Copy link
Member

ACK ACK!

@LudwigKnuepfer
Copy link
Member

..and thanks for bearing..

@rousselk
Copy link
Contributor Author

@LudwigOrtmann You're welcome; I saw you had some work on this item lately (for native if I remember correctly...)

@LudwigKnuepfer
Copy link
Member

I automated it: #1181

@LudwigKnuepfer
Copy link
Member

@rousselk Hooray, Travis likes your PR =)

@LudwigKnuepfer
Copy link
Member

@rousselk Do you want to merge it?

@thomaseichinger
Copy link
Member

Yay, @rousselk it's your honour to push the button.

@rousselk
Copy link
Contributor Author

OK, time has come.

rousselk added a commit that referenced this pull request May 16, 2014
Zolertia Z1 port for RIOT OS
@rousselk rousselk merged commit 988de6b into RIOT-OS:master May 16, 2014
@LudwigKnuepfer
Copy link
Member

Congratulations =)

@rousselk
Copy link
Contributor Author

Thanks everyone, especially Thomas: I think I would still be wondering what's wrong with USB/UART if you didn't give me the finger.
This is a collective achievement.

@thomaseichinger
Copy link
Member

\o/ Congratulations! Happy I could help and looking forward to your next PR!

@rousselk rousselk deleted the z1-port branch May 16, 2014 11:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Platform: MSP Platform: This PR/issue effects MSP-based platforms Type: new feature The issue requests / The PR implemements a new feature for RIOT
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants