AP_RangeFinder: Load .data section for HC-SR04 PRU driver used by BBBMINI

This adds .data section loading to the HC-SR04 range finder driver used by
BBBMINI. The firmware is running inside a PRU. It is necessary to develop more
complex driver software inside the PRU.
This commit is contained in:
mirkix 2016-01-18 20:54:43 +01:00 committed by Lucas De Marchi
parent 417176c0b2
commit 2d9b230be1
2 changed files with 20 additions and 1 deletions

View File

@ -63,7 +63,7 @@ bool AP_RangeFinder_BBB_PRU::detect(RangeFinder &_ranger, uint8_t instance)
*ctrl = 0;
hal.scheduler->delay(1);
// Load firmware
// Load firmware (.text)
FILE *file = fopen("/lib/firmware/rangefinderprutext.bin", "rb");
if(file == NULL)
{
@ -79,6 +79,24 @@ bool AP_RangeFinder_BBB_PRU::detect(RangeFinder &_ranger, uint8_t instance)
munmap(ram, PRU0_IRAM_SIZE);
ram = mmap(0, PRU0_DRAM_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, mem_fd, PRU0_DRAM_BASE);
// Load firmware (.data)
file = fopen("/lib/firmware/rangefinderprudata.bin", "rb");
if(file == NULL)
{
result = false;
}
if(fread(ram, PRU0_DRAM_SIZE, 1, file) != 1)
{
result = false;
}
fclose(file);
munmap(ram, PRU0_DRAM_SIZE);
// Map PRU RAM
ram = mmap(0, 0x1000, PROT_READ | PROT_WRITE, MAP_SHARED, mem_fd, PRU0_DRAM_BASE);
close(mem_fd);

View File

@ -11,6 +11,7 @@
#define PRU0_IRAM_SIZE 0x2000
#define PRU0_DRAM_BASE 0x4a300000
#define PRU0_DRAM_SIZE 0x2000
struct range {
uint32_t distance;