Skip to content

Commit

Permalink
Merge pull request #476 from Koheron/v0.19
Browse files Browse the repository at this point in the history
V0.19
  • Loading branch information
jeanminet committed Aug 30, 2018
2 parents 629d288 + f133d0d commit c7dc81e
Show file tree
Hide file tree
Showing 22 changed files with 123 additions and 2,331 deletions.
30 changes: 25 additions & 5 deletions boards/alpha250/patches/devicetree.patch
@@ -1,5 +1,5 @@
diff -rupN devicetree.old/pcw.dtsi devicetree/pcw.dtsi
--- devicetree.old/pcw.dtsi
diff -rupN devicetree.orig/pcw.dtsi devicetree/pcw.dtsi
--- devicetree.orig/pcw.dtsi
+++ devicetree/pcw.dtsi
@@ -13,9 +13,11 @@
};
Expand Down Expand Up @@ -35,10 +35,30 @@ diff -rupN devicetree.old/pcw.dtsi devicetree/pcw.dtsi
};
&uart0 {
device_type = "serial";
diff -rupN devicetree.old/system-top.dts devicetree/system-top.dts
--- devicetree.old/system-top.dts
@@ -62,7 +74,7 @@
};
&usb0 {
dr_mode = "host";
- phy_type = "ulpi";
+ usb-phy = <&usb_phy0>;
status = "okay";
};
&clkc {
diff -rupN devicetree.orig/system-top.dts devicetree/system-top.dts
--- devicetree.orig/system-top.dts
+++ devicetree/system-top.dts
@@ -23,8 +23,21 @@
@@ -14,6 +14,10 @@
bootargs = "console=ttyPS0,115200 root=/dev/mmcblk0p2 ro rootfstype=ext4 earlyprintk rootwait earlycon";
stdout-path = "serial0:115200n8";
};
+ usb_phy0: phy1 {
+ #phy-cells = <0>;
+ compatible = "usb-nop-xceiv";
+ };
aliases {
ethernet0 = &gem0;
serial0 = &uart0;
@@ -23,8 +30,21 @@
};
memory {
device_type = "memory";
Expand Down
37 changes: 11 additions & 26 deletions boards/alpha250/patches/fsbl/AtmelAtsha204a.c
Expand Up @@ -14,7 +14,7 @@

#include "AtmelAtsha204a.h"
#include "I2cInterface.h"
#include "TimerInterface.h"
#include "sleep.h"
#include "UtilityFunctions.h"


Expand Down Expand Up @@ -164,14 +164,10 @@ EN_RESULT AtmelAtsha204a_Wake(bool verifyDeviceIsAtmelAtsha204a)
// Required data bytes to fulfil tWLO: 1 (8 bits, 8 clocks @ 100kHz, 80us)
uint8_t dummyWriteData = 0x00;

#ifdef _DEBUG
EN_PRINTF("Attempting to wake Atmel ATSHA204A device...\r\n");
#endif

I2cWrite(0, 0, EI2cSubAddressMode_OneByte, (uint8_t*)&dummyWriteData, 0);

// Wait for the device to wake up.
SleepMilliseconds(ATMEL_ATSHA204A_WAKE_TIME_MILLISECONDS);
// Wait for the device to wake up.
usleep(1000*ATMEL_ATSHA204A_WAKE_TIME_MILLISECONDS);

if (verifyDeviceIsAtmelAtsha204a)
{
Expand All @@ -195,7 +191,7 @@ EN_RESULT AtmelAtsha204a_Wake(bool verifyDeviceIsAtmelAtsha204a)

if (expectedResponse != actualResponse)
{
EN_PRINTF("Received response code %x %x %x %x when trying to wake Atmel ATSHA204A \r\n",
xil_printf("Received response code %x %x %x %x when trying to wake Atmel ATSHA204A \r\n",
readBuffer[0],
readBuffer[1],
readBuffer[2],
Expand All @@ -205,10 +201,6 @@ EN_RESULT AtmelAtsha204a_Wake(bool verifyDeviceIsAtmelAtsha204a)
}
}

#ifdef _DEBUG
EN_PRINTF("Atmel ATSHA204A device woken.\r\n");
#endif

return EN_SUCCESS;
}

Expand Down Expand Up @@ -393,7 +385,7 @@ EN_RESULT AtmelAtsha20a4_CheckResponseCrc(const uint8_t* pResponse)

if (receivedCrc != expectedCrc)
{
EN_PRINTF("Atmel ATSHA204 CRC error: expected 0x%x, received 0x%x\r\n", expectedCrc, receivedCrc);
xil_printf("Atmel ATSHA204 CRC error: expected 0x%x, received 0x%x\r\n", expectedCrc, receivedCrc);

return EN_ERROR_ATSHA204A_INVALID_RESPONSE_CRC;
}
Expand Down Expand Up @@ -428,27 +420,27 @@ EN_RESULT AtmelAtsha20a4_CheckCommandResponseBlock(const uint8_t* pResponseBlock

case EStatusCode_InvalidMac:
{
EN_PRINTF("Atmel ATSHA204A error - invalid MAC\r\n");
xil_printf("Atmel ATSHA204A error - invalid MAC\r\n");
return EN_ERROR_ATSHA204A_INVALID_MAC;
}
case EStatusCode_ParseError:
{
EN_PRINTF("Atmel ATSHA204A error - parse error\r\n");
xil_printf("Atmel ATSHA204A error - parse error\r\n");
return EN_ERROR_ATSHA204A_PARSE_ERROR;
}
case EStatusCode_ExecutionError:
{
EN_PRINTF("Atmel ATSHA204A error - execution error\r\n");
xil_printf("Atmel ATSHA204A error - execution error\r\n");
return EN_ERROR_ATSHA204A_EXECUTION_ERROR;
}
case EStatusCode_AfterWake:
{
EN_PRINTF("Atmel ATSHA204A error - first command after wake\r\n");
xil_printf("Atmel ATSHA204A error - first command after wake\r\n");
return EN_ERROR_ATSHA204A_FIRST_COMMAND_AFTER_WAKE;
}
case EStatusCode_IoError:
{
EN_PRINTF("Atmel ATSHA204A error - CRC or other IO error\r\n");
xil_printf("Atmel ATSHA204A error - CRC or other IO error\r\n");
return EN_ERROR_ATSHA204A_IO_ERROR;
}
default:
Expand Down Expand Up @@ -574,21 +566,14 @@ EN_RESULT AtmelAtsha204a_Read(EReadSizeSelect_t sizeSelect,
break;
}

#ifdef _DEBUG
EN_PRINTF("Atmel ATSHA204A: reading %d bytes from zone %d, encoded address %d\r\n",
sizeSelect,
zoneSelect,
encodedAddress);
#endif

uint8_t commandPacket[7];
AtmelAtsha204a_ConstructCommandPacket(ECommand_Read, zone, encodedAddress, 0, NULL, (uint8_t*)&commandPacket);

EN_RETURN_IF_FAILED(AtmelAtsha204a_SendCommand((uint8_t*)&commandPacket, 7));

#ifndef _DEBUG
// Wait for the read command to be processed.
SleepMilliseconds(ATMEL_ATSHA204A_READ_EXECUTION_TIME_MILLISECONDS);
usleep(1000*ATMEL_ATSHA204A_READ_EXECUTION_TIME_MILLISECONDS);
#endif

// Read the response.
Expand Down
2 changes: 1 addition & 1 deletion boards/alpha250/patches/fsbl/AtmelAtsha204a.h
Expand Up @@ -23,7 +23,7 @@
//-------------------------------------------------------------------------------------------------

/// The number of milliseconds it takes for the device to come out of sleep mode
#define ATMEL_ATSHA204A_WAKE_TIME_MILLISECONDS (500)
#define ATMEL_ATSHA204A_WAKE_TIME_MILLISECONDS (10)

/// Average time for the read command to complete, after which polling should start
#define ATMEL_ATSHA204A_READ_EXECUTION_TIME_MILLISECONDS (1)
Expand Down
32 changes: 2 additions & 30 deletions boards/alpha250/patches/fsbl/ErrorCodes.h
Expand Up @@ -9,14 +9,6 @@

#pragma once


//-------------------------------------------------------------------------------------------------
// Includes
//-------------------------------------------------------------------------------------------------

#include "SystemDefinitions.h"


//-------------------------------------------------------------------------------------------------
// Error code definitions
//-------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -92,7 +84,7 @@ typedef enum EN_RESULT
#define EN_PRINT_ERROR(status, message) \
do \
{ \
EN_PRINTF("Error, status code 0x%x: %s\r\n", status, message); \ \
xil_printf("Error, status code 0x%x: %s\r\n", status, message); \ \
} while (0)


Expand Down Expand Up @@ -124,31 +116,12 @@ typedef enum EN_RESULT
EN_RESULT _status = status; \
if (EN_FAILED(_status)) \
{ \
EN_PRINTF("Error: %s (status code = 0x%x)\r\n", message, status); \
xil_printf("Error: %s (status code = 0x%x)\r\n", message, status); \
return _status; \
} \
} while (0)


#if SYSTEM == XILINX_MICROBLAZE
/**
* This macro is used to handle errors in calls to the Xilinx Microblaze driver functions.
*/
#define RETURN_IF_XILINX_CALL_FAILED(x, returnCode) \
do \
{ \
int _status = x; \
if (_status != XST_SUCCESS) \
{ \
return returnCode; \
} \
} while (0)
#endif

#if SYSTEM == XILINX_ARM_SOC
/**
* This macro is used to handle errors in calls to the Xilinx Microblaze driver functions.
*/
#define RETURN_IF_XILINX_CALL_FAILED(x, returnCode) \
do \
{ \
Expand All @@ -158,4 +131,3 @@ typedef enum EN_RESULT
return returnCode; \
} \
} while (0)
#endif
56 changes: 0 additions & 56 deletions boards/alpha250/patches/fsbl/GlobalTypes.h

This file was deleted.

0 comments on commit c7dc81e

Please sign in to comment.