Skip to content

Suggested fixes #183

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

Merged
merged 33 commits into from
Nov 13, 2020
Merged

Suggested fixes #183

merged 33 commits into from
Nov 13, 2020

Conversation

ianfixes
Copy link
Collaborator

@ianfixes ianfixes commented Oct 16, 2020

Trying it out

You can test this beta of the gem directly from github by putting this in your Gemfile:

gem 'arduino_ci', git: 'https://github.com/ianfixes/arduino_ci.git', branch: '2020-10-16_suggestions'

Highlights from CHANGELOG.md

Added

  • arduino_ci_remote.rb CLI switch --skip-examples-compilation
  • CppLibrary.header_files to find header files
  • LibraryProperties to read metadata from Arduino libraries
  • CppLibrary.library_properties_path, CppLibrary.library_properties?, CppLibrary.library_properties to expose library properties of a Cpp library
  • CppLibrary.arduino_library_dependencies to list the dependent libraries specified by the library.properties file

Changed

  • CppLibrary functions returning C++ header or code files now respect the 1.0/1.5 library specification

Deprecated

  • arduino_ci_remote.rb CLI switch --skip-compilation

Fixed

  • Don't define ostream& operator<<(nullptr_t) if already defined by Apple
  • CppLibrary.in_tests_dir? no longer produces an error if there is no tests directory
  • The definition of the _SFR_IO8 macro no longer produces errors about rvalues
  • See CHANGELOG.md for more

Issues Fixed

@@ -5,6 +5,15 @@ Mock Arduino.h library.
Where possible, variable names from the Arduino library are used to avoid conflicts

*/

// hardware mocks
volatile long long __ARDUINO_CI_SFR_MOCK[1024];
Copy link
Member

Choose a reason for hiding this comment

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

I believe that if you defined a variable in a header file then it gets defined every time that header file is included and you get multiple definitions. Instead, if you define it as extern in the header and then put it in a .cpp file, it will be created only once.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also, I think this should declare a uin8_t* array, rather than a long long array. If not, I think that each byte in the original "address space" (i.e. offsets passed to _SFR_IOx macros) end up in different long long entries in this array, so multi-byte values do not map properly anymore (i.e. ADC maps to either ADCH or ADCL (dunno which off-hand), rather than being a combination of both).

Also, the current code violates strict type aliasing (accessing a longlong[] through a pointer of a different type is not allowed), which means the compiler might mess up optimizations regarding this array. I was hoping that making it a uint8_t array would solve this, but it seems this only works the other way around (accessing an arbitrary type through a uint8_t*). So maybe this needs access through a union to make it explicit to the compiler what's happening...

Copy link
Collaborator

@matthijskooijman matthijskooijman left a comment

Choose a reason for hiding this comment

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

Just had a look at the io.h stuff, that (the last commit, the first one that "fixes" _SFR_IO8 only makes it broken in a different way) looks pretty much like what I had in mind for the first part of #193 (comment)

#define _SFR_IO16(io_addr) (*(volatile uint16_t *)(__ARDUINO_CI_SFR_MOCK + io_addr)) // this macro is all we need from the sfr file
#define _SFR_MEM8(io_addr) (*(volatile uint8_t *)(__ARDUINO_CI_SFR_MOCK + io_addr)) // this macro is all we need from the sfr file
#define _SFR_MEM16(io_addr) (*(volatile uint16_t *)(__ARDUINO_CI_SFR_MOCK + io_addr)) // this macro is all we need from the sfr file
#define _SFR_MEM32(io_addr) (*(volatile uint32_t *)(__ARDUINO_CI_SFR_MOCK + io_addr)) // this macro is all we need from the sfr file
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would leave this stuff in io.h, which is where they are used and what any other code that (god knows why) uses them would expect them.

Copy link
Member

Choose a reason for hiding this comment

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

I'm looking at this and right now the issue is that SampleProjects/TestSomething/test/godmode.cpp fails the spi tests due to bytes being in the wrong order.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure what you mean here? If you move this to io.h, that makes the tests fail? But not because of include order or something like that, but "byte order"?

Copy link
Member

Choose a reason for hiding this comment

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

Just for completeness, this conversation is continuing in #201.

@ianfixes
Copy link
Collaborator Author

Reverting 8180efb as per this #196 (comment)

@ianfixes ianfixes force-pushed the 2020-10-16_suggestions branch from 8180efb to 9192004 Compare November 11, 2020 03:25
@ianfixes ianfixes mentioned this pull request Nov 11, 2020
@ianfixes ianfixes force-pushed the 2020-10-16_suggestions branch from 9192004 to cdf136f Compare November 11, 2020 03:37
@ianfixes ianfixes mentioned this pull request Nov 11, 2020
@ianfixes ianfixes force-pushed the 2020-10-16_suggestions branch from cdf136f to f981320 Compare November 11, 2020 04:08
@ianfixes ianfixes added this to the OpenAcidification Support milestone Nov 11, 2020
@ianfixes ianfixes force-pushed the 2020-10-16_suggestions branch 2 times, most recently from 12d4ae7 to b0efa36 Compare November 11, 2020 04:29
@ianfixes ianfixes force-pushed the 2020-10-16_suggestions branch 10 times, most recently from 643caab to 53437a9 Compare November 13, 2020 05:07
@ianfixes ianfixes force-pushed the 2020-10-16_suggestions branch from 53437a9 to cbccf6a Compare November 13, 2020 05:15
@ianfixes ianfixes force-pushed the 2020-10-16_suggestions branch from 25ae225 to ebfa6a7 Compare November 13, 2020 05:49
@ianfixes ianfixes merged commit a438a59 into Arduino-CI:master Nov 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants