What is $x$ in the formula?
$512p=2^9p=x^3-1=(x-1)(x^2+x+1)$. Note that $x^3$ is odd (and hence $x$ is odd) since it's an even number plus $1$. When $x$ is odd, then $x^2+x+1$ is also odd and $x-1$ is the only even factor which implies that $p=x^2+x+1$ and $2^9=x-1$ (otherwise $p$ would not be prime or odd). Hence, the only possible solution could be $2^9=x-1\implies x=2^9+1\implies p=(2^9+1)^2+2^9+2$ which is not prime (it's divisible by $7$). Hence, there are no solutions where $p$ must be prime.