How to run baremetal application on Altera Cyclone V SoC using HPS loading from SD card - embedded

I have a Terasic DE1-SoC board and I want to run a simple led-blinking baremetal application with using HPS.
I've learned HPS tech ref, HPS Boot guide, SoC EDS guide and followed all instructions to run my app.
Here's a brief list of my steps.
Create a system in QSYS with HPS component and some PIOs (for on-board leds and buttons)
Run bsp-editor to create a preloader. I want to run from SD card so I check BOOT_FROM_SDMMC option. Also i want my app to be in FAT partition (check FAT_SUPPORT, FAT_BOOT PARTITION 1, FAT_LOAD_PAYLOAD_NAME test.img (or should it be test.bin?)) Uncheck WATCHDOG_ENABLE. I want to see booting of preloader process in serial connection, so I check SERIAL_SUPPORT. Other settings keep unchanged.
Type "make" in SOC EDS 15.0 command shell to obtain preloader-mkpimage.bin
Write preloader-mkpimage.bin by typing alt-boot-disk-util on sd card with FAT32 partition and custom partition A2.
Create simple app in DS-5, compile it and obtain test.axf then convert it to test.bin using fromelf command and then convert it in test.img with mkimage tool.
Drag-n-drop test.img on sd card FAT32 partition.
Insert it in board and power up
Load .sof on board (my system FPGA-HPS)
Reset HPS by pressing reset button
So the problem is that there is nothing going on in serial connection so i thing that preloader isn't working at all, HPS reset not helping.
I don't see even "<0>" in terminal, just blank page.
I've tried prebuilt images with linux provided by Terasic they are working on 100%.
I do everything according altera docs but nothing is working.
Even official example altera-socfpga-hardwarelib-unhosted isn't working. I've tried to use their preloader from example, but in terminal window I see only "<0>" symbol when I reset HPS.
By the way App is working only in debugger DS5 with inserted SD card and loaded .sof file on board. I don't clearly understand the meaning and the way of writing of .scat file. Don't understand what load address and entry point should I use when I use mkimage tool when converting test.bin->test.img (should i do this convertion or use in BSP settings test.bin???) In my opinion main problem is incorrect preloader. What is the problem with it?
Please help!
UPD: After editing HPS part in QSYS (UART module was added) and re-generating system and re-building preloader (other previous settings was not changed) I started to receive correct messages in terminal about successfull loading of U-boot SPL. But still can't run test.img. Working on it.
UPD2: Ok, I solved this problem, now it's working fine

Related

How to add double tap detection to sample app gatt_sensordata_app?

I am developing an Android app that gets data from Movesense using the GATT profile from the sample app GATT Sensor Data App here.
I followed the tutorial available here. Building the app and getting the DFU worked fine. I can get IMU, HR and temperature data with no issues.
Now I'd like add a tap detection feature to my app. I understand that I have to subscribe to 'System/States', but first I need to be able to receive the system state data.
I understand that I need a modified DFU for that, but I don't understand what changes I should make in which files of the gatt_sensordata_app before rebuilding and generating the new DFU.
What changes should I make in order to broadcast /System/State data?
(I usually just deal with Android so apologies for the very basic question.)
I tried adding #include "system_states/resources.h" to GATTSensorDataClient.cpp but I don't know how to continue.
The normal data straming in the gatt_sensordata_app uses the sbem-encoding code that the build process generates when building the firmware. However /System/States is not among the paths that the code can serialize. Therefore the only possibility is to implement the States-support to the firmware.
Easiest way is to do as follows:
In your python app call data subscription with "/System/States/3" (3 == DOUBLE_TAP)
Add a special case to the switch in onNotify which matches the localResourceId to the WB_RES::LOCAL::SYSTEM_STATES_STATEID::LID
In that handler, return the data the way you want. Easiest is to copy paste the "default" handler but replace the code between getSbemLength() & writeToSbemBuffer(...) calls with your own serialization code
Full disclosure: I work for the Movesense team

Unable to start the chipKit BasicIOShield with PIC32 using PICKIT3 programmer

I have chipKit uC32 (PIC32MX340F512H) ,chipkit BasicIOShield and PICkit3
programmer all from the Microchip.
I'm using MPLABX IDE.
Since I'm very new to this so I didn't know where to start I have searched and look at the web and find only tutorial which using MPIDE which I'm not allowed to use in my project.
I have read the Reference manual and Data sheet for and make test project but any way the uC32 Board refuse to recognize the BasicIOShield and I was unable to connect this two together.
Any tips and link would be great. Thanks in advance.
In the Basic IO shield Reference manual stated that you should follow some step in order to make the ChipKit to talk to the basic IO shield.
Power on sequence
Apply power to VDD.
Send Display Off command.
Initialize display to desired operating mode.
Clear screen.
Apply power to VBAT.
Delay 100ms.
Send Display On command.
Power off sequence
Send Display Off command.
Power off VBAT.
Delay 100ms.
Power off VDD.
The shield is using SPI2. The following registers are used
RF4, RF5, RF6 and RG9
Also you must change the jumper in the uC32 from LED4 to JP4 and JP8.
in the Appendix B of the reference manual of the basic IO shield is an example code which is useful.

How to connect to my LaunchPad TM4C123G

I have spent some time trying to connect to my LaunchPad TM4C123G using the mspdebug toolchain on my macbook (10.10), but no luck.
While trying to run $ mspdebug rf2500 I get
usbutil: unable to find a device matching 0451:f432
I did some googling and it seems to me the mspdebug toolkit might not be suitable for my version of the LaunchPad. Could this be?
After checking my $ system_profiler SPUSBDataType I got the following:
Product ID: 0x00fd
Vendor ID: 0x1cbe (Texas Instruments - Stellaris)
Version: 1.00
Serial Number: 0E205EE1
Speed: Up to 12 Mb/sec
Manufacturer: Texas Instruments
Location ID: 0x14100000 / 14
Current Available (mA): 500
Current Required (mA): 250
This indicates to me that at least the OS is able to recognise the device, right? If so, what other toolchain could I use to connect to the device.
As a satisfactory solution for the time being I started using Energia. I still had to search for the appropriate settings in order to run anything on my LaunchPad TM4C123G. So I decided to spare people some time, and decided to post a step by step walkthrough here.
First, plug in the USB to MicroUSB cable to the top slot of the LaunchPad, as so. And make sure the switch (at the top left) is switched to the "DEBUG" position.
Next download the Energia IDE, there's a nice bundle for the Mac on their site. Once you're done with the setup, open it and search the toolbar for the "Board" section. Once there, select the appropriate setting. In my case it was the one with the checkmark in the screenshot.
Finally, to make sure everything is OK, try and run the provided empty program on your board with the "Upload" button.
If the connection was established and your source compiled and delivered, the status area should look similar to this one.

Memory Address Range - F7FFF000 converted to what command line option?

First, appreciate you giving this a look. I have an ancient piece of software that writes old Linear PCMCIA cards. In my case, I want to use it in a specialized piece of gear called a Tech2. The software in question is called Memory Card Explorer. Now, I know for a fact it works in Windows XP with Native PCMCIA slots. However, I have a slot that is built on a Dual Systems adapter (basically an Expresscard to PCMCIA adapter).
The issue arises when following the instructions on installation issues, the program refuses to locate the Dual Adapter. Here's the example given in the manual:
"Use a similar address to the PCMCIA adapter. That address can be found using msinfo32.exe.
Eg: if the PCMCIA socket has a memory resource of F8000000 then use a MCE window command of F80D0000 using command line option of WF80D0."
So I get my adapter address which is F7FFF000 but have no idea where to add the "d" to the resource address then change it to a command. I've tried WF7FD0. Am I missing something simple in how these addresses are truncated for command line? Is there a calculator that does the conversion for you somewhere?
Thanks.
It looks like the pattern is to add 0x000D0000 to the address, take the five high nibbles of the address (which makes sense, since these sorts of addresses are typically page-aligned the bottom 3 nibbles will always be 0 on a system with 4KiB pages), and prepend 'W'. Try WF80CF.

Mac OS X: Getting detailed process information (specifically its launch arguments) for arbitrary running applications using its PID

I am trying to detect when particular applications are launched.
Currently I am using NSWorkspace, registering for the "did launch application" notification. I also use the runningApplications method to get apps that are currently running when my app starts.
For most apps, the name of the app bundle is enough. I have a plist of "known apps" that I cross check with the name of that passed in the notification.
This works fine until you come across an app that acts as a proxy for launching another application using command line arguments.
Example: The newly released Portal on the Mac doesn't have a dedicated app bundle. Steam can create a shortcut, which serves as nothing more than to launch the hl2_osx app with the -game argument and portal as it's parameter.
Since more Source based games are heading to the Mac, I imagine they'll use the same method to launch, effectively running the hl2_osx app with the -game argument.
Is there a nice way to get a list of the arguments (and their parameters) using a Cocoa API?
NSProcessInfo comes close, offering an `-arguments' method, but only provides information for its own process...
NSRunningApplication offers the ability to get information about arbitrary apps using a PID, but no command line args...
Is there anything that fills the gap between the two?
I'm trying not to go down the route of spawning an NSTask to run ps -p [pid] and parsing the output... I'd prefer something more high level.
You could use whatever ps uses, though it isn't cocoa based. According to Singh, ps is based on kvm and sysctl calls. Pouring over the source, the pertinant calls seem to be kvm_openfiles, kvm_getprocs and kvm_getargv. To get the command line arguments, first call kvm_openfiles to get access to the kernel memory space, then use kvm_getprocs to get kernel process info, then kvm_getargv.
The use of sysctl in ps seems less relevant to your goal; it's used to get other information, such as the group ID and parent proces ID. The particular sysctl name used is {CTL_KERN, KERN_PROC, KERN_PROC_which, flags}, where which specifies a process filter (e.g. ALL, PID) and flags are arguments for the filter (the details are in the sysctl man page).
OS X doesn't have support procfs, but Singh developed a FUSE based version, released under GPLv2. If you bundle it with your application, you'll have to release it under GPLv2 as well. Most of MacFUSE is released under a BSD-style license, so it can be distributed with your app without making it open source (fusefs/fuse_nodehash.c is released under Apple's open source license, but it also allows linking to closed source apps).
The question "Get other process' argv in OS X using C" should be of use, as it has sample code using kvm and sysctl. TN 2050 "Observing Process Lifetimes Without Polling" may also be of use to you.
Nope - running ps is your best bet. Standard process info interfaces aren't supported on OS X (noop versions were provided in OS X 10.4, but removed thereafter) and the private interfaces are likely to change between OS X revisions.
If you're willing to lock yourself into a single OS X version, all the source is available, for example for ps or libproc; you'll also need to run as root.